Row handle referred to a deleted row... error message
am 27.07.2005 13:25:52 von iam247
Hi
I am a relative beginner with SQL and ASP. With some help after
previous posts I have a page which successfully requests querystrings
from another page and deletes a record from an access table, However, I
get the error message:
"Row handle referred to a deleted row or a row marked for deletion"
I am using access 2002, the table only has 2 fields (ContactID and
GroupID, both numeric and joint Primary Keys.
I have another page which successfully deletes a record from another
table with no problems.
I have listed the full code below.
I would grealtly appreciate any help available.
Thanks Colin
<%
' LeaveGroup.asp is called by LeaveGroupSelect.asp and deletes the
selected record from the database-->
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGC1 'Holds the recordset for the record to be deleted
Dim strSQL 'Holds the SQL query to query the database
Dim GroupID
Dim ContactID
'Read in the GroupID to be deleted
GroupID = Request.QueryString("GroupID")
'Read in the ContactID to be deleted
ContactID = Request.QueryString("ContactID")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less
connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("../databases/GC1.mdb")
'Create an ADO recordset object
Set rsGC1 = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT * FROM tblGroupContact WHERE ContactID = " & ContactID
& " AND GroupID = " & GroupID
'Set the lock type so that the record is locked by ADO when it is
deleted
rsGC1.LockType = 3
'Open the recordset with the SQL query
rsGC1.Open strSQL, adoCon
'Remove this group from the members list
rsGC1.Delete
'The response.write's below were used to verify the values below - when
setting up sql
' When activated they confirm that the correct values are being
modified / deleted
'and the correct record is actually deleted from the database - beu
then I get the error message
'Row handle referred to a deleted row or a row marked for deletion
%>
'<%Response.Write (rsGC1("ContactID"))%>
'<%Response.Write (rsGC1("GroupID"))%>
'<%Response.Write ContactID%>
'<%Response.Write GroupID%>
<%
'Reset server objects
rsGC1.Close
Set rsGC1 = Nothing
Set adoCon = Nothing
Response.Redirect "LeaveGroupconfirm.asp"
%>
Re: Row handle referred to a deleted row... error message
am 28.07.2005 01:05:04 von Tim Williams
The best way to delete records is to use a "DELETE from..." SQL statement.
You don't need to open a recordset for this.
You can check the "records affected" parameter to see how many records (if
any) were deleted.
dim lngRecs
strSQL = "DELETE FROM tblGroupContact WHERE ContactID = " & ContactID
& " AND GroupID = " & GroupID
objConn.Execute strSQL, lngRecs, 1
'lngRecs now has the number of records deleted
Tim.
--
Tim Williams
Palo Alto, CA
wrote in message
news:1122463552.085410.101690@g49g2000cwa.googlegroups.com.. .
> Hi
>
> I am a relative beginner with SQL and ASP. With some help after
> previous posts I have a page which successfully requests querystrings
> from another page and deletes a record from an access table, However, I
> get the error message:
>
> "Row handle referred to a deleted row or a row marked for deletion"
>
> I am using access 2002, the table only has 2 fields (ContactID and
> GroupID, both numeric and joint Primary Keys.
>
> I have another page which successfully deletes a record from another
> table with no problems.
>
> I have listed the full code below.
>
> I would grealtly appreciate any help available.
>
> Thanks Colin
>
> <%
> ' LeaveGroup.asp is called by LeaveGroupSelect.asp and deletes the
> selected record from the database-->
>
> 'Dimension variables
> Dim adoCon 'Holds the Database Connection Object
> Dim rsGC1 'Holds the recordset for the record to be deleted
> Dim strSQL 'Holds the SQL query to query the database
> Dim GroupID
> Dim ContactID
>
> 'Read in the GroupID to be deleted
> GroupID = Request.QueryString("GroupID")
>
> 'Read in the ContactID to be deleted
> ContactID = Request.QueryString("ContactID")
>
> 'Create an ADO connection object
> Set adoCon = Server.CreateObject("ADODB.Connection")
>
> 'Set an active connection to the Connection object using a DSN-less
> connection
> adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
> Server.MapPath("../databases/GC1.mdb")
>
> 'Create an ADO recordset object
> Set rsGC1 = Server.CreateObject("ADODB.Recordset")
>
> 'Initialise the strSQL variable with an SQL statement to query the
> database
>
> strSQL = "SELECT * FROM tblGroupContact WHERE ContactID = " & ContactID
> & " AND GroupID = " & GroupID
>
> 'Set the lock type so that the record is locked by ADO when it is
> deleted
> rsGC1.LockType = 3
>
> 'Open the recordset with the SQL query
> rsGC1.Open strSQL, adoCon
>
> 'Remove this group from the members list
> rsGC1.Delete
>
> 'The response.write's below were used to verify the values below - when
> setting up sql
> ' When activated they confirm that the correct values are being
> modified / deleted
> 'and the correct record is actually deleted from the database - beu
> then I get the error message
> 'Row handle referred to a deleted row or a row marked for deletion
> %>
> '<%Response.Write (rsGC1("ContactID"))%>
> '<%Response.Write (rsGC1("GroupID"))%>
>
> '<%Response.Write ContactID%>
> '<%Response.Write GroupID%>
>
> <%
> 'Reset server objects
> rsGC1.Close
> Set rsGC1 = Nothing
> Set adoCon = Nothing
>
> Response.Redirect "LeaveGroupconfirm.asp"
> %>
>