Deleting A Recordset

Results 1 to 5 of 5

Thread: Deleting A Recordset

  1. #1
    James Stansfield Guest

    Default Deleting A Recordset

    Hi, I have a problem with a MS Access db that is being referenced to my website via ODBC connections... The problem is simple, how do I delete a recordset?<BR>Once I open a recordset with a simple SQL command such as:<BR>SELECT * FROM table WHERE ID=1<BR>I find that if I issue the command:<BR>rs.delete<BR>I get the following error:<BR>---<BR>VBScript Errors Occured:<BR>Error Number=3704<BR><BR>Error Descr.=The operation requested by the application is not allowed if the object is closed.<BR><BR>Help Context=0<BR><BR>Source=Microsoft VBScript runtime error<BR><BR>---<BR>Can anyone help me?<BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    41

    Default RE: Deleting A Recordset

    What do you mean, "Delete a recordset?" Do you want to delete a row in a table? Or an entire table? Or a set of rows in a table? Or are you wanting to delete the ASP recordset object? All of these things can be accomplished, I just need to know what you are trying to do, exactly! :) From your code, it appears as though you are wanting to delete a row in a table.<BR><BR>In my opinion, the easiest way to do this is to use a SQL command. If you want to delete the row where ID = 1, just run this SQL query:<BR><BR>DELETE FROM table WHERE ID=1<BR><BR>Hope this helps.

  3. #3
    James Stansfield Guest

    Default RE: Deleting A Recordset

    Ah! Yes that&#039s exactly what I want to do. Thank you.

  4. #4
    Join Date
    Dec 1969
    Posts
    236

    Default RE: Deleting A Recordset

    But what if you are building your tables dynamically? How do you code for "deleting the current recordset?" (one row from the table...)


  5. #5
    asphack Guest

    Default RE: Deleting A Recordset

    Ok, well what if you have 2 or more primary key restraints on that record you are trying to delete? How do you at the same time delete the other 2 records in the 2 tables with the restraints using the same delete statement?<BR><BR>I am using the following (in ASP):<BR><BR>dim RecordToDelete<BR>RecordToDelete=CInt(Request.Form ("ID"))<BR>dim cmd<BR>Set cmd=Server.CreateObject("ADODB.Command")<BR>cmd.Ac tiveConnection=oConn<BR>cmd.CommandText="DELETE FROM Table1,Table2,Table3 WHERE Table1.ID=" & RecordToDelete & " AND Table2.ID=" & RecordToDelete & " AND Table3.ID=" & RecordToDelete<BR>cmd.Execute<BR>rs.Requery &#039This was the recordset created earlier<BR><BR>So, I keep getting an Incorrect Syntax error Microsoft OLE DB Provider for SQL Server error &#039 80040e14&#039. What&#039s the problem with my sql statement?

Posting Permissions

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