Solved

stored  procedure parameters

Posted on 2004-09-02
13
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 23

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Excel Web Add-in Where is Visual Basic used 9 71
wrapping text in datagridview header columns 1 27
Read oracle BLOB in vb.net 2 23
GUID's in SQL Server 4 29
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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