?
Solved

VB.NET and Stored Procedure Parameter

Posted on 2006-06-26
4
Medium Priority
?
246 Views
Last Modified: 2008-02-26
It seems that no matter what I do, I keep getting the following error:
Prodedure 'CreateSession' expects parameter '@Result', which was not supplied - .NET SqlClient Data Provider
-------------------

Here is my code... Im sure I'm overlooking something... but I just can't find it.

-------------------

Dim pAppurl As New SqlParameter("@appurl", SqlDbType.VarChar, 250, ParameterDirection.Input)
            Dim pCurrurl As New SqlParameter("@currurl", SqlDbType.VarChar, 250, ParameterDirection.Input)
            Dim pUservalue As New SqlParameter("@uservalue", SqlDbType.VarChar, 50, ParameterDirection.Input)
            Dim pUserip As New SqlParameter("@Userip", SqlDbType.VarChar, 20, ParameterDirection.Input)
            Dim pTimeout As New SqlParameter("@timeout", SqlDbType.Int, 2, ParameterDirection.Input)
            Dim pGUID As New SqlParameter("@Result", SqlDbType.VarChar, 50)
            pGUID.Direction = ParameterDirection.ReturnValue

            Try
                If oConn.State <> ConnectionState.Open Then
                    oConn.Open()
                End If

                Dim oCmdSP As New SqlCommand
                oCmdSP.CommandType = CommandType.StoredProcedure
                oCmdSP.CommandText = "CreateSession"
                oCmdSP.Connection = oConn

                pAppurl.Value = strAppurl
                pCurrurl.Value = strCurrurl
                pUservalue.Value = strUservalue
                pUserip.Value = strUserip
                pGUID.Value = ""

                oCmdSP.Parameters.Add(pAppurl)
                oCmdSP.Parameters.Add(pCurrurl)
                oCmdSP.Parameters.Add(pUservalue)
                oCmdSP.Parameters.Add(pUserip)
                oCmdSP.Parameters.Add(pGUID)

                If intTimeout <> 0 Then
                    pTimeout.Value = intTimeout
                    oCmdSP.Parameters.Add(pTimeout)
                End If

                oCmdSP.ExecuteNonQuery()
0
Comment
Question by:Michael Krumpe
[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
4 Comments
 
LVL 12

Expert Comment

by:vb_jonas
ID: 16987193
Looks fine, how does the sql-procedure look? And why do you set the pGUID.Value=""?
0
 
LVL 4

Author Comment

by:Michael Krumpe
ID: 16987251
The stored proc is declared as follows

ALTER PROCEDURE [dbo].[CreateSession]
      @appurl varchar(250),
      @currurl varchar(250),
      @uservalue varchar(50),
      @userip varchar(20),
      @timeout int = 0,
      @Result varchar(50) OUTPUT
AS


--------------

I just stuck that pGUID.Value = "" because I kept getting this same error and thought maybe I needed to push "something" to it.

Any thoughts?
0
 
LVL 4

Accepted Solution

by:
sr101880 earned 2000 total points
ID: 16987631
You need to change:

pGUID.Direction = ParameterDirection.ReturnValue


to

pGUID.Direction = ParameterDirection.Output

Let me know if you have any questions.
0
 
LVL 2

Expert Comment

by:Bill_PSC
ID: 16987802
Try this

oCmdSP.SelectCommand.Parameters(pAppurl).Value = pAppurl
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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