Hi,
Is it possible to capture the value returned from executing a SQL statement executed through the Code Behind window?
I have a script that works fine, and the VB in the code behind window also works fine. However, I want to expand the VB script if possible, so that I can execute the following algorithm:
Open connection to database
Execute SQL statement to check if value exists in a database table
If the value exists then
Do this
Otherwise
Do this
End If
Close connection to database
Is it possible to capture the value returned from executing a SQL statement executed through the Code Behind window?
I have a script that works fine, and the VB in the code behind window also works fine. However, I want to expand the VB script if possible, so that I can execute the following algorithm:
Open connection to database
Execute SQL statement to check if value exists in a database table
If the value exists then
Do this
Otherwise
Do this
End If
Close connection to database
What I need to understand is how to get a result back from an execution statement such as:
thisCommand.CommandText = "SELECT myValue FROM DatabaseTable"
thisCommand.ExecuteNonQuery()
Is this possible? Is there a better way? If so, what do I need to do to make it happen?
When I run the following code, the value returned to my variable aResult is always -1, regardless of whether the search succeeds or not:
SQL_Command = "SELECT * FROM LookupItemsTexts WHERE [Text] = 'fred'"Log.WriteLine(SQL_Command) 'debug line'Now execute the commandthisConnection.Close() thisConnection.Open()thisCommand.CommandText = SQL_CommandaResult = thisCommand.ExecuteNonQuery()Log.WriteLine(aResult.ToString()) 'debug lineThanks,
Nigel Edwards.