Hi
When i am trying like this :
cmd.CommandText = "select LastName,FirstName,EmailAddress,MobilePhone from contactdetails where LastName = 'gutta' "; my code executing perfect when i am giving static data like gutta ...
BUT
I am getting no error .. .. ..
when i am trying like this ..
cmd.CommandText = "select LastName,FirstName,EmailAddress,MobilePhone from contactdetails where LastName = " + textBox1.Text ;
ERROR IS :
dr = cmd.ExecuteReader(); ------------------>
Invalid column name 'gutta'.
Regards


VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 7:57 AM EST
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 14, 2014, 8:11 AM EST
Ty so much your help Helps :)
I feel confused sometimes .. The same thing i used somewhere in cascading dropdownlists its working fine but here in the above senario its popping me error ..
MY LAST senario which didnt give me any sort of error is
cmd.CommandText = "select state,stateid from countrystate where countryid=" + DropDownList1.SelectedValue;
Any ideas y :)
VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 8:28 AM EST
Only strings and dates need quotes. Numbers don't.
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 14, 2014, 8:51 AM EST