• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1564
  • Last Modified:

ASP Classic ADODB.Field error '80020009'

Hi,

I am getting this error and after many tries, I gave up on banging my head on my keyboard and I am sure it's something (..) I forget here.

I am trying to verify if the email exist in my table before inserting a new entry. Simple enough, But I always get this

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

And I can't gert rid of it...

Help... Please...

Here is my code...
Dim useraction
Dim Email
Dim Action
Dim SQL
 
Email = lcase(request.form("Courriel"))
useraction = request.form("Join_Quit")
 
set RS = server.createobject("adodb.recordset")
SQL = "SELECT * FROM ListeWow WHERE Courriel = '" & Email & "'"
RS.open SQL, conn, 2, 2
 
If (request.form("Courriel") = "") Then
	Action = "Adresse courriel invalide. veuillez recommencer."
Else
	select case useraction
	case "Join"
		if Not RS.eof then
			RS.addnew
			RS("Courriel") = Email
			RS("Name_Last") = request.form("Name_Last")
			RS("Name_First") = request.form("Name_First")
			RS("Date_In") = Date
			RS.update			
			Action = "Bienvenue sur notre liste d'envois."
		else
			Action = "Vous êtes déjà inscrit."
		end if
	case "Quit"
		if Not RS.eof then
			Action = "Vous n'êtes pas membre."
		else			
			sql2="DELETE FROM ListeWow WHERE Courriel = '" & Email & "'"
			conn.execute(sql2)
			
			Action = "Votre adresse courriel a été retirée."
		end if
	end select
End If
 
RS.close
set RS = nothing

Open in new window

0
SirTKC
Asked:
SirTKC
  • 6
  • 4
1 Solution
 
Pratima PharandeCommented:
add conn.Open and conn.close
Dim useraction
Dim Email
Dim Action
Dim SQL
 
Email = lcase(request.form("Courriel"))
useraction = request.form("Join_Quit")
 
set RS = server.createobject("adodb.recordset")
SQL = "SELECT * FROM ListeWow WHERE Courriel = '" & Email & "'"
conn.Open(connection string)
RS.open SQL, conn, 2, 2
 
If (request.form("Courriel") = "") Then
	Action = "Adresse courriel invalide. veuillez recommencer."
Else
	select case useraction
	case "Join"
		if Not RS.eof then
			RS.addnew
			RS("Courriel") = Email
			RS("Name_Last") = request.form("Name_Last")
			RS("Name_First") = request.form("Name_First")
			RS("Date_In") = Date
			RS.update			
			Action = "Bienvenue sur notre liste d'envois."
		else
			Action = "Vous êtes déjà inscrit."
		end if
	case "Quit"
		if Not RS.eof then
			Action = "Vous n'êtes pas membre."
		else			
			sql2="DELETE FROM ListeWow WHERE Courriel = '" & Email & "'"
			conn.execute(sql2)
			
			Action = "Votre adresse courriel a été retirée."
		end if
	end select
End If
 
RS.close
set RS = nothing

Open in new window

0
 
SirTKCAuthor Commented:
Hi Pratima,

The conn.open and conn.close are not included in my snippet because these are parts of included asp pages
connopen.asp and connclose.asp

Also, I already went through the hyperlink you provided to me here. It did not solved my problem.

This is the included connopen.asp on the top of the page
 
<%
dim dsn
dim Conn
dsn="DBQ=" & Server.Mappath("mydata.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open dsn
%>
 
And this is the included connclose.asp at the end of the page
 
<%
Conn.close
set Conn = nothing
%>

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Pratima PharandeCommented:
Make sure that
Courriel , Name_Last,Name_First,Date_In  are returning from query as same you have written
0
 
Pratima PharandeCommented:
RS.addnew  ?
Is it needed ?
0
 
SirTKCAuthor Commented:
Yes I need to add a new record.

Maybe I should reverse my question.

I simply want to verify that the email exist in the table before inserting a new contact. This should be easy - but not for me obviously :-/

I also verified (10X) that all names are OK and that the form is passing all data perfectly well. Indeed it does !


0
 
Pratima PharandeCommented:
then instade of uing RS.Update
user normal insert stament and Excute it

sql2="Insert inot........"


                  conn.execute(sql2)
0
 
SirTKCAuthor Commented:
I finaly found the bug...

it was not the code above at all that was in cause... OMG...
It was a tag lower in the page calling a field that is no longer in this table.

I am sorry for the trouble, but the code above is good.

But your suggestions pushed me to look somewhere else !

Thanks pratima
0
 
SirTKCAuthor Commented:
thanks !
0
 
Pratima PharandeCommented:
welcome :)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now