Solved

stored  procedure parameters

Posted on 2004-09-02
13
260 Views
Last Modified: 2010-04-23
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
Comment
Question by:sandeep437
13 Comments
 
LVL 7

Expert Comment

by:natloz
ID: 11967539
Try
cmd.Parameters.Add(New SqlParameter("@OrgCode", SqlDbType.VarChar, 10)) = CStr(something)
0
 

Author Comment

by:sandeep437
ID: 11967565
tried this. but not working. saying expression is a value and cannot be target of expression.

thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967591
Or:

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

Bob
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:natloz
ID: 11967602
This is what I use...

Imports System.Data
Imports System.Data.SqlClient
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967614
Forgot:

cmd.Parameters.Add(param)

Bob
0
 
LVL 7

Accepted Solution

by:
natloz earned 50 total points
ID: 11967625
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967634
Or that way will work, too:)

Bob
0
 
LVL 22

Expert Comment

by:Snarf0001
ID: 11968958
you're using c# syntax, in vb it's

cmd.Parameters("").Value = something

( not [
0
 
LVL 4

Expert Comment

by:Javert93
ID: 11974540
Is there a reason why you are not specifying the name of the parameter? I should be:

    cmd.Parameters("@OrgCode").Value = something
0
 
LVL 2

Expert Comment

by:ahmadfuwad
ID: 12083188
///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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question