Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL statment problems

    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

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    Pilipinas
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

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

    Sales Summary

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

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

    see http://authors.aspalliance.com/aspxt....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 + "'"
    Last edited by ReyN; 10-18-2003 at 03:06 AM.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excellent thanks

    Thanks ReyN
    that worked a treat, so close but so far away sometimes right.
    Regards
    Daryl


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •