Print Page | Close Window

Updating individual records

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7718
Printed Date: 31 March 2026 at 9:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Updating individual records
Posted By: simflex
Subject: Updating individual records
Date Posted: 29 November 2003 at 12:29pm

I have been struggling with this code now for 2 days.
Our client requires that we have 2 screens.
The first screen allows them to enter an id to be updated.
Once they click the submit button, they are taken to the second screen where records associated with the id are displayed.
One of those  records includes a dropdown menu; in this case, they are allowed to select a different record from the dropdown to be updated.
Once all records to be modified have been modified, the user then clicks save to save new modified records to the database.

No matter what I did, I keep getting this error message:

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

I know this means that no records are found but there are records on the database.
Below is my entire code.
Any help is greatly appreciated.

<%
Dim mode
mode=request.form("search")
set my_conn= Server.CreateObject("ADODB.Connection")
my_Conn.Open "DSN=guestbook"
sql="select * from guestbook"
set crs = my_Conn.execute(sql)
'Exeute this query and collect records in recordset crs
if mode<>"" then
code=request.form("code")
sql="select * from guestbook where ID=" & code
set crs = my_Conn.execute(sql)
'response.write sql
'response.end

'Execute this query and collect records in recordset rs
end if

if request.form("update")<>"" then
'collect the values from the form and update the database
end if
%>
<html>
<body>
<form name="f1" action="editJob.asp" method="post">
Enter Class Code:&nbsp;
<%if mode="" then%>
<input type=text name="code">
<input type=submit name="search" value="submit">
<%else%>
Class Code
<select name="code">
<%
while not crs.eof
if code=crs("id") then%>
<option selected value="<%=crs("id")%>"><%=crs("id")%></opt ion>
<%else%>
<option value="<%=crs("id")%>"><%=crs("id")%></opt ion>
<%end if
crs.movenext
wend%></select><br>
Title
<input type=text name="city" value="<%=crs("name")%>"><br>
Date
<input type=text name="state" value="<%=crs("city")%>"><br>
Name
<input type=text name="dob" value="<%=crs("dte")%>"><br>
<input type=submit name="update" value="save">
<%end if%>
</form>
</body>
</html>

 




Replies:
Posted By: Mart
Date Posted: 29 November 2003 at 12:32pm
http://www.webwiz.net/asp/faq/access_database_faq.asp#FAQ7 - http://www.webwiz.net/asp/faq/access_database_faq.asp#F AQ7


Posted By: theSCIENTIST
Date Posted: 30 November 2003 at 6:42am

I haven't dwelve much into your code, but let me ask you this:

On your 2nd screen the records shown are those associated with that ID?

You seem to be passing the ID with POST from 1st screen to 2nd screen, are you sure that from the 2nd screen you pass the ID in the way the update page expects it?

Are you sure you are passing the currect ID to the update query?

Can you view the database at all stages of the process to ensure your code is not messing up at some point?

Thx.



Posted By: pmormr
Date Posted: 30 November 2003 at 9:19am
make sure that you surround the ID value in your select statement with "'" (apostrophe ' ' ' ' ' ' )

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Mart
Date Posted: 30 November 2003 at 9:23am
Its the wrong way round Make sure you dont surround the ID value with apostrophes if its an autonumber



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net