|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Updating Error
I am having a problem with my update code below(sorry about the length). It works fine if I try to update any of the fields I havent use to select the record. However if I try to update the field used to select the record it gives me the following error:
Either BOF or EOF is True, or the current record has been deleted ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. I cannot figure out why it wont work can someone please help. update_select_adult_title.asp <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Update Adult Title</title> </head> <body> <% 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsCommittee 'Holds the recordset for the records in the database Dim strSQL 'Holds the SQL query for the database 'Create an ADO connection odject 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("MoneygallGAA.mdb") 'Create an ADO recordset object Set rsCommittee = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT Adult_Titles.* FROM Adult_Titles;" 'Open the recordset with the SQL query rsCommittee.Open strSQL, adoCon %> <p align="center"> <b> Please click on Title you wish to update</b> </p> <table border="1" width="70%" bgcolor="#FFFFFF" align="center" bordercolor="#FF0000"> <tr> <th><font color="#000000">Year</font></th> <th><font color="#000000">Title</font></th> </tr> <% 'Loop through the recordset Do While not rsCommittee.EOF 'Write the HTML to display the current record in the recordset %> <tr> <td align="center"><font color="#000000"> <% Response.Write ("<a href=""updateadulttitlesform.asp?Year=" & rsCommittee("Year") & """>") Response.Write (rsCommittee("Year")) Response.Write ("</a>")%></font></td> <td align="center"><font color="#000000"><%Response.Write (rsCommittee("Title"))%></font></td> <% 'Move to the next record in the recordset rsCommittee.MoveNext %> </tr> <% Loop %> </table> <% 'Reset server objects rsCommittee.Close Set rsCommittee = Nothing Set adoCon = Nothing %> <p align="center"> <a href="administrator_menu.asp">Administrator Main Menu</a></p> </body> </html> update_adult_titles.asp 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsUpdateEntry 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query for the database Dim lngRecordNo 'Holds the record number to be updated 'Read in the record number to be updated lngRecordNo = CLng(Request.Form("Year")) 'Create an ADO connection odject 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("MoneygallGAA.mdb") 'Create an ADO recordset object Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT * FROM Adult_Titles WHERE Year=" & lngRecordNo 'Set the cursor type we are using so we can navigate through the recordset rsUpdateEntry.CursorType = 2 'Set the lock type so that the record is locked by ADO when it is updated rsUpdateEntry.LockType = 3 'Open the tblComments table using the SQL query held in the strSQL varaiable rsUpdateEntry.Open strSQL, adoCon 'Update the record in the recordset rsUpdateEntry.Fields("Year") = Request.Form("Year") rsUpdateEntry.Fields("Title") = Request.Form("Title") 'Write the updated recordset to the database rsUpdateEntry.Update 'Reset server objects rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing 'Return to the update select page incase another record needs updating Response.Redirect "update_select_adult_title.asp" %> updatetitlesform.asp 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsCommitteeMember 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query for the database Dim lngRecordNo 'Holds the record number to be updated 'Read in the record number to be updated lngRecordNo = CLng(Request.QueryString("Year")) 'Create an ADO connection odject 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("MoneygallGAA.mdb") 'Create an ADO recordset object Set rsCommitteeMember = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT * FROM Adult_Titles WHERE Year=" & lngRecordNo 'Open the recordset with the SQL query rsCommitteeMember.Open strSQL, adoCon %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Update Adult Titles</title> </head> <body> <p> <table bgcolor="#FFFFFF" align="center" border="1" bordercolor="#FF0000"> <tr> <td> <p align="center"><font color="#000000"> <b> Please Enter Title You Wish To Update</font> </p> <b> <!-- Begin form code --> <form name="form" method="post" action="update_adult_titles.asp" onSubmit="return checkval()"> </b> </b> <tr> <td> <p align="center"><font color="0000000">Year: </font><input type="text" name="Year" maxlength="20" value="<% = rsCommitteeMember("Year") %>"> <br> <font color="0000000">Title:</font> <input type="text" name="Title" maxlength="60" value="<% = rsCommitteeMember("Title") %>"> <p align="center"> <br> <input type="submit" name="Submit" value="Submit"> </form> <!-- End form code --> </table> <p align="center"> </p> <p align="center"><a href="administrator_menu.asp">Administrator Main Menu</a></p> </body> </html> <% 'Reset server objects rsCommitteeMember.Close Set rsCommitteeMember = Nothing Set adoCon = Nothing %> |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Updating Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|