I have a query that should always be returning a single int. I have now logged it returning a string entirely unrelated to what it should be.
We\'ve been ge
I think that you were thinking about sqlCommand.ExecuteNonQuery that returns the number of rows affected within an int value...
This is the definition of the ExecuteScalar method:
public override object ExecuteScalar()
Member of System.Data.SqlClient.SqlCommand
Summary:
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
Returns:
The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.
So, I think that the common way of returning that column is as a string representation of the column value.