This is a slight variation of this question. If I have a function that performs an action that returns a value but I did not capture that value in a variable, is there any way I can get that value while stepping through with the debugger without running the function a 2nd time in the immediate window?
A practical example
using (SqlConnection cnSqlConnect = OpenConnection(ConnectionString))
using (SqlCommand sqlCmd = new SqlCommand(command, cnSqlConnect))
{
sqlCmd.ExecuteNonQuery();
}
Is there any way to get the value of sqlCmd.ExecuteNonQuery()
without running it twice?
Using BugAid in Full Mode, you'll be able to see the value that ExecuteNonQuery returned right after you step over it, by using its Statement Visualization feature.
BugAid visualizes the values of every method call, even if that value is not assigned to a variable. It does this without re-evaluating the function (it never causes the method to be executed twice).
For example:
Full disclosure: I am a co-creator of BugAid.
Yes there is!
?
to view the results. Like this:? sqlCmd.ExecuteNonQuery();
This will have the effect of only executing your code once and will let you view the result.
For more information see the Basics of using the Command Window.