Replace save database query variable with value using C# and VB.Net in ASP.Net

Last Reply 3 months ago By alya14

Posted 3 months ago

hi ,

my scenario like below

the PLN is static value I am reading before call query

I stored the query like this
 
SELECT NAME FROM CONTACTS WHERE CODE='" + PLN + "'"
 
and I set to PLN variable in login screen, so if login users=a than PLN=ALY
 
after login I call to string query from DATABASE and watching by sql profiler, the sql profiler show to me
 
SELECT NAME FROM CONTACTS WHERE CODE='" + PLN + "'" 
 
instead of
 
SELECT NAME FROM CONTACTS WHERE CODE='ALY'

How can I do ?

You are viewing reply posted by: alya14 3 months ago.
Posted 3 months ago

I solved this issue using parameters like bellow

I stored like this WHERE CODE=@P1

and call

cmd.parameters.addwithvalue("@P1",PLN)

Thanks for your time.