0

Say we have a query where I will add some parameters

For Ex:

 SqlCommand cmd = new SqlCommand("insert into Table(UserName, Password, Country, Email) values(@UserName, @Password, @Country, @Email)", con);

 cmd.Parameters.AddWithValue("@UserName", User.UserName);
 cmd.Parameters.AddWithValue("@Password", User.Password);
 cmd.Parameters.AddWithValue("@Country", User.Country);
 cmd.Parameters.AddWithValue("@Email", User.Email);

Something like this.

Now I want to display the query result like

insert into Table(UserName, Password, Country, Email) 
values('Test1', '1234', 'India', 'abc@xyz.com')

The values shown will be the parameters that I added.

As far as I know in php when we echo the query and run it in browser we will get the value of parameters. But is there any possibilities here?.

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
NewBie
  • 69
  • 1
  • 11

1 Answers1

1

SQL command text and parameters are send to sql server separately, you can't get the final sql statement using SqlCommand, try using SQL Profiler.

Damith
  • 60,955
  • 13
  • 99
  • 152