VS.NET question: conditional run

  • Thread starter Thread starter in
  • Start date Start date
I

in

In Visual Studio, is there a way of marking a statement as a
"conditional run".

Sort of like a breakpoint, but there, in the debugger, the statement
will not execute.

I'm thinking of code that has calls to production databases, but which I
want to test and yet not write records.

I would want to flag these statements not to execute.

I would prefer not to comment them out, because then I have to remember
to uncomment them.
 
in said:
In Visual Studio, is there a way of marking a statement as a
"conditional run".

Sort of like a breakpoint, but there, in the debugger, the statement
will not execute.

I'm thinking of code that has calls to production databases, but which I
want to test and yet not write records.

I would want to flag these statements not to execute.

You can probably do what you want with the Conditional attribute.
 
Use a conditional value that is only defined in your RELEASE build, and
not in your DEBUG build. You can define the conditional values at the
command line of your compiler, or from the Project Properties in VS.NET.

In your code it would look like

#ifdef RELEASE
cmd.ExecuteNonQuery(); // inserts record to production database
#endif
 
Back
Top