Skip to content

Passing Parameters to Stored Procedure

oc A

Asked Feb 14, 2008, 8:28 PM EST1 answer
Share
LinkedInX

Parameters are passed to Stored Procedure from VB.NET Application like

Dim param As SqlParameter
param = New SqlParameter("@name",DbType.String)
param.Direction = ParameterDirection.Input
param.Value = "ABC"
comand.Parameters.Add(param)

But is there any way to specify parameters without specifying the
parameter name and type like

Dim param As SqlParameter
param = New SqlParameter
param.Direction = ParameterDirection.Input
param.Value = "ABC"
comand.Parameters.Add(param)


But when i try like this i am getting an error saying that "Parameter1 is not a parameter in the procedure"...

I cannot make any changes in the Stored Procedure
Can anybody tell me how to solve this .
Thanx in advance

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Hi,

    Dim param As SqlParameter
    param = New SqlParameter
    param.Direction = ParameterDirection.Input
    param.Value = "ABC"
    comand.Parameters.Add(param)

    In the abovge code you have to mention the parameter name like this

    param.ParameterName= "@name"

    if you are passing a value means definitely it should gave a name.

     

    if your procedure is not having any input parameters then dont add any parametrs to the sqlcommand,just mention the procedure name.

     

    Thanks

    0