|
 |
asp_databases thread: So Curious...
Message #1 by "Debra Delaney" <ddelaney@v...> on Thu, 26 Apr 2001 22:08:00
|
|
Re: Chapter 14 in Beg. ASP 3.0, "Deleting Records Using a Recordset"
Delete.asp example.
Does anyone know how to get rid of this error message? See below.
(Line 21 is "objRS.MoveNext" in the While Wend loop).
I have tried so many things, If then else, break, do while,
exit do, counters, etc.,etc. Nothing has worked except to
put an "on error resume next" statement in the loop.
Thank you from Debra.
344
345
346
347
348
Provider error '80040e23'
Row handle referred to a deleted row or a row marked for deletion.
/Project4/AddRecord/Delete.asp, line 21
Message #2 by "Ken Schaefer" <ken@a...> on Sat, 28 Apr 2001 00:50:27 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Re: Chapter 14 in Beg. ASP 3.0, "Deleting Records Using a Recordset"
: Delete.asp example.
:
: Does anyone know how to get rid of this error message? See below.
: (Line 21 is "objRS.MoveNext" in the While Wend loop).
:
: I have tried so many things, If then else, break, do while,
: exit do, counters, etc.,etc. Nothing has worked except to
: put an "on error resume next" statement in the loop.
: Thank you from Debra.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't have the book handy, can you post the code?
From memory though, the problem with that bit of code is that you create a
recordset. You are on the last record (or you are not .EOF), then you delete
that record, and then you do a .movenext (since you weren't .EOF), but since
you deleted the last record, you are now .EOF, and so .movenext fails.
You need to put a check in before .movenext to check for .EOF again:
Do While Not objRS.EOF
objRS.Delete
If not objRS.EOF then
objRS.movenext
End if
Loop
Cheers
Ken
Message #3 by "Debra Delaney" <ddelaney@v...> on Mon, 30 Apr 2001 20:48:50
|
|
Thank you Ken for your help. Here is the code.
Problem still in While Wend loop with objRS.MoveNext.
Tried your suggestion Ken and still get an
"HTTP 500 - Internal server error Internet Explorer".
Delete.asp
<%Option Explicit%>
<!--#include file="datastore.asp"-->
<!--#include file="adovbs.inc"-->
<html>
<head>
<title>Adding a New Record</title>
</head>
<body>
<h1>This is a test</h1>
<%
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "Movies", strConnect, adOpenStatic, adCmdTable
objRS.Filter = "Title = 'Seven'"
Do While Not objRS.EOF
Response.Write objRS.Fields("MovieID") & "<br>"
objRS.Delete
If Not objRS.EOF Then
objRS.MoveNext
End If
Loop
objRS.Close
Response.Write "<br>Just to check:<br>"
objRS.Open "Select * from Movies where Title Like 'Seven'", _
strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
If objRS.EOF Then
Response.Write "All records of Seven have been removed from the
database<br>"
Else
Response.Write "Seven still exists in the database, " & _
"at the record with MovieID=" & objRS("MovieID")
End If
objRS.Close
Set objRS = Nothing
%>
</body>
</html>
---------------------------------------------------------------------------
----
Wrote this to add records to database.
AddNew.asp
<%Option Explicit%>
<!--#include file="datastore.asp"-->
<!--#include file="adovbs.inc"-->
<html>
<head>
<title>Adding a New Record</title>
</head>
<body>
<h1>This is a test</h1>
<%
Dim objRS, intIDForNewRecord
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "Movies", strConnect, adOpenStatic, adCmdTable
objRS.MoveLast
intIDForNewRecord = CInt(objRS("MovieID")) + CInt(1)
objRS.AddNew
objRS("MovieID") = intIDForNewRecord
objRS("Title") = "Seven"
objRS.Update
objRS.Close
objRS.Open "Select * From Movies Where MovieID=" & intIDForNewRecord, _
strConnect
If objRS.EOF Then
Response.Write "New record not found - something went wrong"
Else
Response.Write "You've successfully added a new record:<br> " & _
"Movie title = '" & objRS("Title") & "'<br>" & _
"MovieID = " & objRS("MovieID")
End If
objRS.Close
Set objRS = Nothing
%>
</body>
</html>
> Re: Chapter 14 in Beg. ASP 3.0, "Deleting Records Using a Recordset"
> Delete.asp example.
>
> Does anyone know how to get rid of this error message? See below.
> (Line 21 is "objRS.MoveNext" in the While Wend loop).
>
> I have tried so many things, If then else, break, do while,
> exit do, counters, etc.,etc. Nothing has worked except to
> put an "on error resume next" statement in the loop.
> Thank you from Debra.
>
> 344
> 345
> 346
> 347
> 348
>
> Provider error '80040e23'
>
> Row handle referred to a deleted row or a row marked for deletion.
>
> /Project4/AddRecord/Delete.asp, line 21
>
>
>
>
|
|
 |