...

View Full Version : SQL statment problems



dawilis
10-18-2003, 01:22 AM
Hi all Can someone look at this a see why Im getting an error

set rs1 = server.createobject("ADODB.Recordset")

if(Request("checkboxName") <> "") then
ID = Replace(Request("checkboxName"),"'",".")
SQL = "DELETE FROM NMContact WHERE IDN IN " + ID + " "
rs1.open sql,constring

end if


he error returned is
Microsoft][ODBC Microsoft Access Driver] In operator without () in query expression 'IDN IN 3, 4, 22'.
/wic/Reception/deleteNoN.asp, line 33


line 33 being the rs1.open.sql,constring

ReyN
10-18-2003, 02:47 AM
hello

the correct syntax for the WHERE ... IN clause would be as follows

strSQL = "SELECT . . . WHERE ProductType IN ('Backpack', 'SleepingBag', 'Supplies', 'Tent')"

the entire parameter must be enclosed within parentheses, and each string in the array ( if the parameter passed is an array ) must be ecnclosed within quotes.

Using the WHERE ... IN clause (http://authors.aspalliance.com/aspxtreme/ado/demos/sql_wherein.asp)

and here is an ADO.NET example of passing arguments to a WHERE ... IN clause dynamically

Sales Summary (http://authors.aspalliance.com/aspxtreme/adonet/demos/Sales%20Summary.aspx)

so in the case you pointed out, it would be like

SQL = "DELETE FROM NMContact WHERE IDN IN ('" + ID + "')"

see http://authors.aspalliance.com/aspxtreme/ado/structuredquerylanguagebasics.aspx?pageno=4 :)

but actually, since you are just passing a single value, you could just instead do

SQL = "DELETE FROM NMContact WHERE IDN = '" + ID + "'" :D

dawilis
10-18-2003, 06:15 AM
Thanks ReyN
that worked a treat, so close but so far away sometimes right.
Regards
Daryl:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum