updating a database using a drop down

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 17th, 2006, 09:59
New Member
Join Date: Jan 2006
Age: 39
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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
%>
Reply With Quote

  #2 (permalink)  
Old Jan 17th, 2006, 16:53
Reputable Member
Join Date: Sep 2003
Location: USA
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #3 (permalink)  
Old Jan 17th, 2006, 17:03
New Member
Join Date: Jan 2006
Age: 39
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #4 (permalink)  
Old Jan 17th, 2006, 20:55
New Member
Join Date: Jan 2006
Age: 39
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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....
Reply With Quote
  #5 (permalink)  
Old Jan 18th, 2006, 01:28
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbramz
Re: updating a database using a drop down

can you use [code] tags next time please..
Reply With Quote
Reply

Tags
updating, database, using, drop, down

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 21:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43