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

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
 
M

Miha Markic

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top