|
 |
asp_databases thread: What am I doing wrong
Message #1 by gailmac1@h... on Wed, 22 Aug 2001 23:44:30
|
|
Here is my error message:ADODB.Recordset error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record. (line 29)
I am trying to have a add new user or update existing user all in the same
coding. I have copied this directly from Chapter 15 Beg ASP and then
changed it to what I need. Any suggestions would be helpful..
Here is my code:
<%
Dim rsUsers
Set rsUsers = Server.CreateObject ("ADODB.Recordset")
rsUsers.Open "UserRegistration", objConn, adOpenForwardOnly,
adLockOptimistic, adCmdTable
If Session("EMail") <> " " Then
rsUsers.Filter = "EMail = '" & Session("EMail") & "'"
Else
rsUsers.Filter = "EMail = ' " & Request.Form("EMail")
& "'" &_
"AND Password = '" & Request.Form("Password") & "'"
If rsUsers.EOF Then
rsUsers.AddNew
End If
End If
rsUsers("EMail") = Request.Form("EMail") 'line 29
rsUsers("Password") = Request.Form("Password")
rsUsers("FirstName") = Request.Form("FirstName")
rsUsers("LastName") = Request.Form("LastName")
rsUsers.Update
Dim strName, strValue
For each strField in rsUsers.Fields
strName =strField.Name
strValue =strField.Value
Session(strName)= strValue
Next
Session("blnValidUder")=True
Response.Redirect "MyProfile.asp"
%>
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 23 Aug 2001 13:48:16 +1000
|
|
No,
Think about what you're doing, please!
What you want to do is:
1) Open Recordset
2) Apply Filter criteria
If session("Email") present then
Use that
Else
Use Request.Form("Email")
End If
3) If recordset is *now* .EOF then
call .AddNew
End If
4) Rest of Code.
If you look at your code, you are doing it like this:
1) Open Recordset
2) Apply Filter criteria
If session("Email") present then
Use that
Else
Use Request.Form("Email")
3) If Recordset now .EOF then
Call .AddNew
End If
End If
4) Rest of Code
Do you see that you are calling .AddNew in the wrong place?
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: <gailmac1@h...>
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, August 22, 2001 11:44 PM
Subject: [asp_databases] What am I doing wrong
: Here is my error message:ADODB.Recordset error '800a0bcd'
:
: Either BOF or EOF is True, or the current record has been deleted.
: Requested operation requires a current record. (line 29)
:
: I am trying to have a add new user or update existing user all in the same
: coding. I have copied this directly from Chapter 15 Beg ASP and then
: changed it to what I need. Any suggestions would be helpful..
:
: Here is my code:
:
: <%
:
: Dim rsUsers
: Set rsUsers = Server.CreateObject ("ADODB.Recordset")
: rsUsers.Open "UserRegistration", objConn, adOpenForwardOnly,
: adLockOptimistic, adCmdTable
:
: If Session("EMail") <> " " Then
: rsUsers.Filter = "EMail = '" & Session("EMail") & "'"
: Else
: rsUsers.Filter = "EMail = ' " & Request.Form("EMail")
: & "'" &_
: "AND Password = '" & Request.Form("Password") & "'"
: If rsUsers.EOF Then
: rsUsers.AddNew
: End If
: End If
:
: rsUsers("EMail") = Request.Form("EMail") 'line 29
: rsUsers("Password") = Request.Form("Password")
: rsUsers("FirstName") = Request.Form("FirstName")
: rsUsers("LastName") = Request.Form("LastName")
: rsUsers.Update
:
: Dim strName, strValue
: For each strField in rsUsers.Fields
: strName =strField.Name
: strValue =strField.Value
: Session(strName)= strValue
: Next
: Session("blnValidUder")=True
: Response.Redirect "MyProfile.asp"
: %>
:
:
:
: ---
: * Fast, Full-Featured Microsoft® Excel Web Reports & Charts!
: A breakthrough in high performance Web application development,
SoftArtisans
: ExcelWriter 1.1 supports native Excel charting, image insertion, and
: advanced functions & formatting. One click generates presentation-quality
: Excel spreadsheets-and ExcelWriter performs over 100 times faster than the
: Excel Object. Several editions, including ExcelWriterFREE, are available.
: http://www.softartisans.com/softartisans/excelwriter.html>
$subst('Email.Unsub')
Message #3 by David Cameron <dcameron@i...> on Thu, 23 Aug 2001 09:54:28 +1000
|
|
*If* you had changed your code to what was suggested earlier there wouldn't
have been a problem. You cannot have had the same code as that before,
otherwise the error would *not* have happened.
With your new and improved code the error is the placement of the If rs.eof
block.
Fixing the section with the error:
If Session("EMail") <> " " Then
rsUsers.Filter = "EMail = '" & Session("EMail") & "'"
Else
rsUsers.Filter = "EMail = ' " & Request.Form("EMail") & "'" &_
"AND Password = '" & Request.Form("Password") & "'"
End If
If rsUsers.EOF Then
rsUsers.AddNew
End If
Think about it. Once you have applied the filter you need to check to see if
the result has been that all records have been filtered out. Doesn't matter
which of the filters you applied.
One other thing, the if block checking the session variable may well also be
wrong. Did you mean:
If Session("EMail") <> "" Then
instead of
If Session("EMail") <> " " Then
regards
David Cameron
nOw.b2b
dcameron@i...
-----Original Message-----
From: gailmac1@h... [mailto:gailmac1@h...]
Sent: Thursday, 23 August 2001 9:45 AM
To: ASP Databases
Subject: [asp_databases] What am I doing wrong
Here is my error message:ADODB.Recordset error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record. (line 29)
I am trying to have a add new user or update existing user all in the same
coding. I have copied this directly from Chapter 15 Beg ASP and then
changed it to what I need. Any suggestions would be helpful..
Here is my code:
<%
Dim rsUsers
Set rsUsers = Server.CreateObject ("ADODB.Recordset")
rsUsers.Open "UserRegistration", objConn, adOpenForwardOnly,
adLockOptimistic, adCmdTable
If Session("EMail") <> " " Then
rsUsers.Filter = "EMail = '" & Session("EMail") & "'"
Else
rsUsers.Filter = "EMail = ' " & Request.Form("EMail")
& "'" &_
"AND Password = '" & Request.Form("Password") & "'"
If rsUsers.EOF Then
rsUsers.AddNew
End If
End If
rsUsers("EMail") = Request.Form("EMail") 'line 29
rsUsers("Password") = Request.Form("Password")
rsUsers("FirstName") = Request.Form("FirstName")
rsUsers("LastName") = Request.Form("LastName")
rsUsers.Update
Dim strName, strValue
For each strField in rsUsers.Fields
strName =strField.Name
strValue =strField.Value
Session(strName)= strValue
Next
Session("blnValidUder")=True
Response.Redirect "MyProfile.asp"
%>
|
|
 |