Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

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

0
sandeep437
Asked:
sandeep437
1 Solution
 
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
 
Bob LearnedCommented:
Or:

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

Bob
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
natlozCommented:
This is what I use...

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

cmd.Parameters.Add(param)

Bob
0
 
natlozCommented:
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
 
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now