For Programmers: Free Programming Magazines  


Home > Archive > C# > May 2005 > SqlClient.SqlCommand getting SQL-query string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SqlClient.SqlCommand getting SQL-query string
remove.com

2005-05-26, 3:59 pm

Hi all.

I'm trying to retrieve the actual SQL-query string from a
SqlClient.SqlCommand object. I have executed something along these lines:

db = new System.Data.SqlClient.SqlConnection(DB_CONNECTION);
db.Open();
sql = "INSERT INTO foo (foo1, foo2) VALUES (@foo1, @foo2)";
cmd = new System.Data.SqlClient.SqlCommand(sql, this.db);
cmd.Parameters.Add("@foo1, "value1");
cmd.Parameters.Add("@foo2, "value2");

And now I want to see the precise sql statement that is going to be
passed when I execute cmd.ExecuteNonQuery(). Is this possible?

Thankyou

Mads Ravn
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com