|
-
Mar 7th, 2001, 02:43 PM
#1
Thread Starter
Hyperactive Member
I am having trouble deleting records from an Access database using the following code. There are 2 SQL statements.
1 - Deletes the record indicated in the QueryString
2 - Deletes all records where the length of one field is less than 3
Here's the code
Code:
<%
Dim cnn
Dim rst
Dim ConnectString
Dim strSQL
Dim strDelSQL
Set cnn = Server.CreateObject("ADODB.Connection")
Set rst = Server.CreateObject("ADODB.Recordset")
ConnectString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("database/tickets.mdb")
strSQL = "DELETE * FROM RRS_Tickets WHERE TicketID = " & Request.QueryString("Record")
strDelSQL = "DELETE * FROM Tickets WHERE Len(Ticket_Number) < 3"
cnn.Open ConnectString
rst.Open strDelSQL, cnn, 2, 2
rst.Close
rst.Open strSQL, cnn, 2, 2
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Response.Redirect("Tickets.asp")
%>
Here's the error I'm getting
Code:
ADODB.Recordset error '800a0e78'
The operation requested by the application is not allowed if the object is closed.
?
Thank you for any help.
If you think education is expensive, try ignorance.
-
Mar 7th, 2001, 02:56 PM
#2
Hyperactive Member
You're pretty close.
use
Code:
cnn.execute strDelSQL, , adcmdtext
cnn.execute strSQL, , adcmdtext
instead of
Code:
rst.Open strDelSQL, cnn, 2, 2
rst.Close
rst.Open strSQL, cnn, 2, 2
rst.Close
-
Mar 7th, 2001, 03:03 PM
#3
Thread Starter
Hyperactive Member
Thanks. What does the adcmdtext part mean?
If you think education is expensive, try ignorance.
-
Mar 7th, 2001, 03:37 PM
#4
Hyperactive Member
The adcmdtext is optional and means that you are passing a text string to execute the command. If you look in your ADO help, you'll find other options such as adCmdTable, adCmdUnkown...
You can also apply those options when opening a recordset.
-
Mar 7th, 2001, 03:40 PM
#5
Thread Starter
Hyperactive Member
If you think education is expensive, try ignorance.
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
|