Record will not delete

Discussion in 'Databases' started by iamdavid, Jun 14, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. HERES THE SCRIPT THAT DON'T WORK:
    Dim myConn, rs, mysql
    SET myConn = CreateObject("ADODB.Connection")
    set rs=Server.CreateObject("ADODB.recordset")

    MyConn = "Provider=SQLOLEDB;Data Source=tcp:*******2.discountasp.net;Initial Catalog=SQL2008_******s;User ID=SQL2008_******_fhs_user;Password=******;"
    [ignore the **** in MyConn of course.]
    cid = request.form("rec_id")
    mysql = "DELETE FROM " & Request.Form("Table_Name") & " WHERE id = '" & cid & "';"

    MyConn.Execute mysql

    AFTER FORM SUBMISSION THIS IS WHAT IS RETURNED:
    table = Visitors record id = 39 [<-from response.write request.form("table_name") & " record id = " & cid]

    DELETE FROM Visitors WHERE id = '39';[<-- from request.write mysql]

    HERES THE ERROR PRODUCED:
    Microsoft VBScript runtime error '800a01a8'

    Object required: 'Provider=SQLOLEDB;Da'

    /delete_record.asp, line 46
    The connection string MyConn works for every thing else like INSERT, SELECT but not DELETE. Anyone have a clue?:confused:
     
  2. Two things I can think of;
    1) Change "id" to this -> WHERE [id]
    2) Catch that form value and make sure you are getting something for: request.form("rec_id")

    i.e. <%= cid %>
     
  3. I changed the id to [id] but still did not work.
    What did work was changing from MyConn.Execute to rs.Open method.
    For others reading this you have to include these lines not found in my original post:
    set rs=Server.CreateObject("ADODB.recordset")
    Rs.Open mysql, MyConn

    And remove the line:
    MyConn.Execute mysql

    Thank You.
     
  4. Good job ;-)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page