I have a user-defined stored procedure which returns a bit value as OUTPUT.
In my calling code I want to check that value.
I define it in my code as follows:
Dim retval As New SqlParameter() retval.ParameterName = "@return" retval.SqlDbType = SqlDbType.Bit retval.Direction = ParameterDirection.Output DataCommand.Parameters.Add(retval) DataCommand.ExecuteNonQuery() ' now check the return value If Not (CBool(retval.Value)) Then Throw New ApplicationException("SQL returned FALSE. ") End If
Which appears to get the desired results, in that my code hits the If statement and continues.
However, if I change the If statement to
If Not (CBool(retval.SqlValue)) ...
I get an exception
Conversion from type 'SqlBoolean' to type 'Boolean' is not valid
How should I be handling this? Insight, comments please.