Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data back from a stored procedure

Status
Not open for further replies.

lyric0n

Technical User
Dec 28, 2005
74
Hello,

I have a stored procedure which takes 3 variables in, modifies one of the variables, which is a bit, then returns it. How would I capture this response with Visual Basic 2005? I have written below what I have tried...

Thanks,
Chris

objProcessCommand.Parameters.Add("@Valid", SqlDbType.Bit, ParameterDirection.ReturnValue)
objProcessCommand.Parameters.Add("@IPAddr", SqlDbType.VarChar, ParameterDirection.Input).Value = strIPAddr
objProcessCommand.Parameters.Add("@MACAddr", SqlDbType.VarChar, ParameterDirection.Input).Value = strMACAddr

objProcessCommand.ExecuteNonQuery()
If objProcessCommand.Parameters(0).Value Then
Console.WriteLine("True")
Else
Console.WriteLine("False")
End If
 
Check to see what the value equals. Here is an example.
Code:
If objProcessCommand.Parameters(0).Value = 1 Then
    Console.WriteLine("True")
Else
    Console.WriteLine("False")
End If
 
I've actually tried that, but with no luck...any other ideas?
 
What is the value of objProcessCommand.Parameters(0).Value?
 
If I use the code above, it is blank, but if I give Parameters(0) a value before I execute my statement, then I get that same value that I assigned back...
 
When you execute the stored procedure in Query Analyzer or Management Studio, what is the value?

I just realized the parameter is a return value and not an output parameter. Return values are integers, so that could be causing a problem.
 
The problem ended up being on the SQL side. The SQL Manager returned the right values, but apparently there were some extra spaces being added to the values before going into the stored procedure, so a RTrim on incoming variables did the trick.

Thanks for the help,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top