3

I Want to display the CommandText of SqlCommand with all parameter value..

When I Use,

MessageBox.Show(cmd.CommandText);

The messagebox just display,

ex: "insert into nasabah values(@nama,@kontak)"

I Want, the messagebox show the query with all parameter values, example:

"insert into nasabah ('Deni','021899999');
Usman
  • 3,200
  • 3
  • 28
  • 47
Deny Ocr
  • 31
  • 1
  • 4
  • 1
    possible duplicate of [Get the generated SQL-Statement from a SqlCommand-Object?](http://stackoverflow.com/questions/265192/get-the-generated-sql-statement-from-a-sqlcommand-object) – Pieter van Ginkel Jun 26 '13 at 04:45
  • just traverse the cmd.Parameters collection, then you will get all the parameters. – ojlovecd Jun 26 '13 at 04:59
  • The parameters are **not** getting substituted into the SQL command text - that's why you're not seeing them. The parameters are sent to SQL Server along side the SQL command text. If you want to show the SQL command text with the actual values, you have to replace the parameter placeholders with the values yourself – marc_s Jun 26 '13 at 05:01

0 Answers0