Results 1 to 2 of 2

Thread: Executing Delete

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    8

    Executing Delete

    i have the following code which i cant get working

    i think i have the SQL correct but dont exactly know where i am going with the execution.

    Please help(the error i get is operation is not allowed when object is closed)

    lastball i a variable that hold the value of a row(primary key)



    strSQL1 = "DELETE FROM Ball" & _
    " WHERE BallNo =" & LastBall

    Set rsBall = New ADODB.Recordset
    rsBall.Open strSQL1, conn, adOpenDynamic, adLockOptimistic

    rsBall.Delete

    rsBall.Close
    Set rsBall = Nothing

    Many thanks

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Executing Delete

    A SQL Delete statement does not create/open a recordset. You would first need to use a SQL Select statement to fetch the record and then call the Recordset.Delete method.

    But there is no need to even use a recordset. Execute the sql statement directly using the Connection.Execute or the Command.Execute method.

    strSQL1 = "DELETE FROM Ball" & _
    " WHERE BallNo =" & LastBall

    conn.Execute strsql1,,adExecuteNoRecords

Posting Permissions

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



Click Here to Expand Forum to Full Width