This is a discussion on "updating a database using a drop down" within the Classic ASP section. This forum, and the thread "updating a database using a drop down are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
updating a database using a drop down
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
updating a database using a drop down
Hi
I am having problems updating my database using a dropdown menu can someone see where I have gone wrong: Error: ADODB.Recordset error '800a0bcd' Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /update_style.asp, line 34 ************************************************** ******* drop down form: <% 'Dimension variables Dim styConn 'Holds the Database Connection Object Dim rsstyle 'Holds the recordset for the records in the database Dim strstyke 'Holds the SQL query for the database Dim lngRecordNo2 'Holds the record number to be updated 'Read in the record number to be updated lngRecordNo2 = Request.QueryString("RemID") 'Create an ADO connection object Set styConn = Server.CreateObject("ADODB.Connection") styconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=ny database connection is here that's not the problem;" 'Create an ADO recordset object Set rsstyle = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strstyle = "SELECT memorial.pagestyle FROM memorial where remid=" & lngRecordNo2 'Open the recordset with the SQL query rsstyle.Open strstyle, styConn %> <form name="form" method="post" action="update_style.asp?remid=<%=lngRecordNo2%>"> <tr> <td width="50%"> <select size="5" name="pagestyle" style="width: 95%;" style="border:1px outset #5286A5; " style="border:1px outset #5286A5; " multiple style="border: 1px outset #5286A5"> <option value="Bible">Bible</option> <option value="boat">boat</option> <option value="candles">candles</option> <option value="child1">child1</option> <option value="child2">child2</option> <option value="cross">cross</option> <option value="diary">diary</option> <option value="footprints">footprints</option> <option value="heaven1">heaven1</option> <option value="landscape">landscape</option> <option value="music">music</option> <option value="ocean">ocean</option> <option value="ponga">ponga</option> <option value="rose">Rose</option> <option value="rose2">Rose2</option> <option value="sky">Sky</option> <option value="toitoi">Toitoi</option> <option value="valley">Valley</option> </select></td> <td width="50%"> <font face="Arial" size="2" color="#5286A5"> Click here to view what each style template looks like.</font></td> </tr> <tr> <td width="100%" colspan="2" align="center"> <input type="submit" value="Submit New Style" name="style" style="color: #FFFFFF; font-weight: bold; border: 1px solid #5286A5; background-color: #5286A5"></td> </tr> </form> <% 'Reset server objects rsstyle.Close Set rsstyle = Nothing Set styCon = Nothing %> ************************************************** * The scripted page after submission: <!-- #INCLUDE FILE="connection.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 to query the database Dim lngRecordNo 'Holds the record number to be updated 'Read in the record number to be updated lngRecordNo = CLng(Request.Form("Remid")) 'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using DSN connection adoCon.Open Connect_String '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 memorial.pagestyle FROM memorial WHERE remid=" & 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 recordset with the SQL query rsUpdateEntry.Open strSQL, adoCon 'Update the record in the recordset rsUpdateEntry.Fields ("pagestyle") = Request.Form ("pagestyle") 'Write the updated recordset to the database rsUpdateEntry.Update DIM strCustomerID strCustomerID = rsupdateentry("remID") 'Reset server objects rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing 'Return to the update select page in case another record needs deleting 'Response.Redirect "update_select.asp" Response.Redirect ("editmemorial.asp?REMID=") & strcustomerid %> |
|
|
|
|||
|
Re: updating a database using a drop down
Which script is generating the error the dropdown dreation or the one to update the database?
In general though it means your select statement isn't returning any records and then you're trying to read from it which it can't, because it's not there. FYI, you shouldn't hold the recordset object open like that. It's a huge performance problem. http://www.learnasp.com/advice/whygetrows.asp |
|
|||
|
Re: updating a database using a drop down
Hi Jakyra
Thanks for your help ... the error accures when the information is submitted ... the second lot of code ... I will take your advice and give it a go |
|
|||
|
Re: updating a database using a drop down
Problem solved
The remid was not being picked up in part of the script .... fixed and now working perfectly.... |
![]() |
| Tags |
| updating, database, using, drop, down |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Drop down menus drop behind flash header | theGAME71135 | Flash & Multimedia Forum | 3 | Jan 10th, 2008 09:42 |
| updating database with password | franknu | PHP Forum | 1 | Oct 23rd, 2006 23:30 |
| updating database | franknu | PHP Forum | 4 | Oct 8th, 2006 20:32 |
| Updating Database Using ASP and XML | cmomah | Classic ASP | 0 | Oct 12th, 2005 20:22 |
| Updating Database Through XML | cmomah | Other Programming Languages | 0 | Oct 12th, 2005 20:21 |