Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

stored  procedure parameters

Posted on 2004-09-02
13
Medium Priority
?
265 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
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.

 
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 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

636 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