Can't delete- messing up the SQL query, I thin

Results 1 to 3 of 3

Thread: Can't delete- messing up the SQL query, I thin

  1. #1
    Jared Rhoads Guest

    Default Can't delete- messing up the SQL query, I thin

    hello, if anyone could help me out with this, I&#039d be very appreciative.<BR><BR>I am trying to delete a record from a database. I am identifying the different records by "listing_id" - so I am trying to go through the database, find the record that has the same listing_id as the one I give it, and then delete it.<BR><BR>I have this snippet code going now (by the way, "events" is the name of the table in the database that I&#039m working with, and EVENTS is the recordset):<BR><BR>sql = "DELETE * FROM events WHERE listing_id = "& Request ("listing_id") & ";"<BR><BR>rsEVENTS.Open sql, db, adOpenForwardOnly, adLockOptimistic, adCmdText<BR><BR>rsEVENTS.Close<BR><BR><BR>But I get this error:<BR>[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression &#039listing_id = , 82&#039. <BR><BR>I&#039m asking because it seems like its probably just a dumb mistake somewhere that I don&#039t know how to fix, but then again I don&#039t really know. Any help?<BR><BR>I tried doing it the other way with the filter method, and then doing rsEVENTS.Delete, but I couldn&#039t get that working either because in the filter method I was using to identify the correct method, I couldn&#039t get it to accept the arguments. I&#039m very frustrated!!<BR><BR>Thank you so much to whomever responds!<BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: Can't delete- messing up the SQL query, I

    &#062;&#039listing_id = , 82&#039. <BR><BR>why the ,?? Your Request ("listing_id") seems to have a , before the 82 check to see why that is happening<BR><BR>Secondly IMO <BR><BR>&#062;rsEVENTS.Open sql, db, adOpenForwardOnly, adLockOptimistic, adCmdText<BR>trash that line...why do you wnat a recordset object for a delete just use connectionName.execute(sql )<BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Can't delete- messing up the SQL query, I

    yeah, I can&#039t figure where the stray comma is coming from... I&#039d better take another look. That&#039s a good recommendation about the sql execute line- I was wondering if there was a better way to do that- I now see that there is. Thanks...

Posting Permissions

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