|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Unable to recognize stored procedure paramI am attempting to create a small app that executes a stored procedure in SQLServer and have been unsuccessful in getting the procedure to execute from my application. The error received when issuing the ExecuteNonQuery is "Procedure 'TestProc' expects parameter '@IN', which was not supplied.". Any help would be greatly appreciated. Below is a test stored proc and code. Thanks, Virgil ---------------------------------------------------------------------------------------------- create procedure TestProc (@IN int ,@OUT int OUTPUT ) as set @OUT = 10 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ConnString As String = "**************" '<-- not displayed Dim Connection As SqlConnection Dim Command As SqlCommand Dim InParam As SqlParameter Dim OutParam As SqlParameter Try ' Create connection Connection = New SqlConnection(ConnString) Connection.Open() ' Create Command Command = New SqlCommand("TestProc", Connection) Command.CommandType = CommandType.StoredProcedure ' Create parameters InParam = New SqlParameter("@IN", SqlDbType.Int) InParam.Direction = ParameterDirection.Input 'Command.Parameters.AddWithValue("@IN", 1) OutParam = New SqlParameter("@OUT", SqlDbType.Int) OutParam.Direction = ParameterDirection.Output ' Add the parameters to the command Command.Parameters.Add(InParam) Command.Parameters.Add(OutParam) ' Execute the command Command.ExecuteNonQuery() ' Show results MessageBox.Show(Command.Parameters(1).Value) Catch ex As Exception MessageBox.Show(ex.Message) Finally If (Connection Is Nothing) = False Then If Connection.State = ConnectionState.Open Then Connection.Close() End If End If End Try End Sub
Show quote
Hide quote
> Hello, You neglected to set the value property of InParam. > > I am attempting to create a small app that executes a stored procedure > in SQLServer and have been unsuccessful in getting the procedure to > execute from my application. The error received when issuing the > ExecuteNonQuery is "Procedure 'TestProc' expects parameter '@IN', > which was not supplied.". > ' Create parameters > InParam = New SqlParameter("@IN", SqlDbType.Int) > InParam.Direction = ParameterDirection.Input > 'Command.Parameters.AddWithValue("@IN", 1) > ' Add the parameters to the command > Command.Parameters.Add(InParam) Jim Wooley Doh! I was thinking that the error message was tellnig me it could not
find the param. Thanks a bunch!
delete row from dataview
Problem: Unwanted Paper feed after printing. problems with URL value in webbrowser app Delimiter question File test fonts at runtime Modules in 2005 Property 'FlowBreak' accessible only at design mode ? Read a text file word by word Intermittent VS.Net Pauses during VB.NET code writing |
|||||||||||||||||||||||