How to view to be submitted query string in ADO.NET

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi, I am kind of new to ADO.NET. I have a question about ADO.NET query:

IDbCommand command = this.DbConnection.CreateCommand();
command.CommandText = "delete device where device_id=@device_id";
IDbDataParameter param = command.CreateParameter();
param.ParameterName = "@device_id";
param.Value = id;
command.Parameters.Add(param);

In above statement, is ther e a way for me to see the actual sql statment
after parameter is substituted? for example, if id ="deviceId1", the actual
sql statement to be executed is :

delete device where device_id='deviceId1'.

is there a way to examine the statement before it is executed?

Thanks

Paul
 
Hi Paul,

The parameter isn't substitued but instead passed along the query, so there
is nothing more to see for you.
Perhaps you could take a look with Sql profiler - you'll see the same: query
and beneath the query a list of parameter values.
 
Back
Top