English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello,
I 'd like to print out the print out sql statement in asp.net 2.0 Gridviewprint out sql statement in asp.net 2.0 Gridview. Tried to use SqlDataSource1.UpdateCommand, but it doesn't print out the values of parameters.
thanks,

2006-09-25 10:04:49 · 1 answers · asked by eclamshell 1 in Computers & Internet Programming & Design

1 answers

You can catch the code before the update in the SqlDataSource.Updating Event. Open the SqlDataSource1 properties window and double-click in the Updating field. Write this code (or similar):

protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
string strSQL = SqlDataSource1.UpdateCommand;
foreach(DbParameter parameter in e.Command.Parameters)
{
strSQL = strSQL.Replace(
parameter.ParameterName,
parameter.Value.ToString());
}
lblSQL.Text = strSQL;
}

For string types, you may want to wrap the value in single quotes depending on whether you are actually going to run this SQL against the database once you retrieve it.

2006-09-28 16:07:45 · answer #1 · answered by Brian G 3 · 0 0

fedest.com, questions and answers