C# .NET - c# code for sql not in clause - Asked By saif on 25-Sep-12 04:14 AM

i have a textbox where values are in the form like (2012,2013,2036).

i need to pass these textbox value in sql query like:

select *from stock where c_code not in ('"+textbox+"')

m getting error when i execute it.its showing cannot convert string to numeric (30,6).

Kindly help.


Robbe Morris replied to saif on 25-Sep-12 07:54 AM
If c_code is a varchar/nvarchar type, you'll need to surround each item in the not in clause with a single quote. 
Jitendra Faye replied to saif on 26-Sep-12 02:00 AM
Before passing values to query add single quote for each value which you want to match.