Murray Brown
asked on
VB.net SQL make sure only single value returned
Hi. I am using the following code to pull a single result from a SQL table.
I need a way to check if the result returns more than one value first.
Is there a way to build that into this code? If not what code would I need
to run first to see if there is a single value returned for this SQL statement
Dim connection As New SqlConnection(oConnectionS tring)
Dim cmd As New SqlCommand(sSQL, connection)
connection.Open()
oResult = cmd.ExecuteScalar.ToString
If IsDBNull(oResult) = True Then
Get_Value = "Null"
Else
Get_Value = oResult
End If
connection.Close()
I need a way to check if the result returns more than one value first.
Is there a way to build that into this code? If not what code would I need
to run first to see if there is a single value returned for this SQL statement
Dim connection As New SqlConnection(oConnectionS
Dim cmd As New SqlCommand(sSQL, connection)
connection.Open()
oResult = cmd.ExecuteScalar.ToString
If IsDBNull(oResult) = True Then
Get_Value = "Null"
Else
Get_Value = oResult
End If
connection.Close()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER