|
-
Feb 6th, 2005, 02:01 PM
#1
Thread Starter
New Member
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
-
Feb 6th, 2005, 03:08 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|