Sachin Singh

Sachin Singh

  • 10
  • 55.8k
  • 75k

is there a way to check query after parameters are applied?

Dec 28 2020 2:07 PM
Consider below query , i am passing (--  double dash in username to bypass password)
  1. SqlCommand cmd=new SqlCommand("Select * from users where username=@UserName and Password=@password",con ); 
Now, i am passing username as Sachin'-- and with password field empty.
 
According to me , the query now becomes 
  1. Select * from users where username='Sachin'--' and Password=''   
 As you can see, it seems like i am successfully able to bypaas Password , i just wanted to know how the query is constructed when parameters are used , cause obviously it prevents SQL injection.
 
Please take the same example and clearify.

Answers (4)