stored procedure parameters

i am using stored procedure in .aspx.vb file

used imports.data.sqlclient
        imports.data.sqltypes

OrgCode is an input parameter for stored procedure

//vb code
cmd.Parameters.Add(New SqlParameter("@OrgCode", SqlDbType.VarChar, 10))
cmd.Parameters[""].value = something

i am not able to add parameter value. intellisense in not coming when trying to add value to parameter.

any suggestions for this

thanks

sandeep437Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
natlozConnect With a Mentor Commented:
Here is a sample...

'*************************************
                'Populate lblName with the user's name
                '*************************************
                'SQL Database statements
                oComm = New SqlCommand
                oComm.CommandType = CommandType.StoredProcedure
                oComm.CommandText = "spGetUser"
                oComm.Connection = oConn

                'Send in parameters
                oComm.Parameters.Add(New SqlParameter("@pkUserID", SqlDbType.Int)).Value = _intUserID
0
 
natlozCommented:
Try
cmd.Parameters.Add(New SqlParameter("@OrgCode", SqlDbType.VarChar, 10)) = CStr(something)
0
 
sandeep437Author Commented:
tried this. but not working. saying expression is a value and cannot be target of expression.

thanks
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
Bob LearnedCommented:
Or:

Dim param As SqlParameter = New SqlParameter("@OrgCode", SqlDbType.VarChar, 10))
param.Value = CStr(something)

Bob
0
 
natlozCommented:
This is what I use...

Imports System.Data
Imports System.Data.SqlClient
0
 
Bob LearnedCommented:
Forgot:

cmd.Parameters.Add(param)

Bob
0
 
Bob LearnedCommented:
Or that way will work, too:)

Bob
0
 
Snarf0001Commented:
you're using c# syntax, in vb it's

cmd.Parameters("").Value = something

( not [
0
 
Javert93Commented:
Is there a reason why you are not specifying the name of the parameter? I should be:

    cmd.Parameters("@OrgCode").Value = something
0
 
ahmadfuwadCommented:
///store procedure

CREATE PROCEDURE  spGetEmployess

      @ID      Int

AS

      Select * From Employee Where ID = @ID
GO

///calling of store procedure in VB.NET

cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "spGetEmployess"

        param = New SqlClient.SqlParameter("@ID", SqlDbType.Int)
        param.Value = ComboBox1.Text
        cmd.Parameters.Add(param)

        reader = cmd.ExecuteReader
        reader.Read()
0
All Courses

From novice to tech pro — start learning today.