I wrote it out like you showed but haven't been able to work a bug out
of it. When I have 2 parameters added (the stored procedure returns 2
strings, it doesn't take anything), I'm trapping an error "Procedure
priority_high has no parameters and arguments were supplied.
If I remark out the two parameters.add lines and run it, it passes the
executenonquery line and when I go to display in a message box the 2
strings It's supposed to return I trap the error "An sqlparameter with
parametername '@mBTN' is not contianed by this SqlParameter Collection."
Any ideas?
Code snipit
Dim HighSqlCommand As New SqlClient.SqlCommand
HighSqlCommand.Connection = mySqlConnection
HighSqlCommand.CommandType = CommandType.StoredProcedure
HighSqlCommand.CommandText = "priority_high"
HighSqlCommand.Parameters.Add("@mBTN", SqlDbType.Char = 6)
HighSqlCommand.Parameters.Add("@mUID", SqlDbType.Char = 10)
mySqlConnection.Open()
Try
HighSqlCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Execute error: " & ex.Message)
End Try
mySqlConnection.Close()
Try
MessageBox.Show(HighSqlCommand.Parameters("@mBTN") .ToString
& " " & HighSqlCommand.Parameters("@mUID").ToString)
Catch ex As Exception
MessageBox.Show("MessageBox error: " & ex.Message)
End Try
Brian Henry wrote:
how is it passing back strings? in parameters or in a table? if its a table
with multiple rows or columns you need a data adapter.... if it is using
output parameters you need only a command object with the parameters its
coming back marked as output direction.
dim cmd as sqlclient.sqlcommand("SP_Proc",databasecon)
cmd.commandtype = commandtypes.storedprocedure
cmd.parameters.add("@retstring1",nvarchar(100))
cmd.parameters("@retstring1").direction = output
cmd.executenonquery()
debug.writeline(cmd.paramter("@restring1").value.t ostring)
that isnt entirely the correct names and methods but that should show you
what to do to get an output param back if that is how you are doing it