recordset

E

Eugene Anthony

asp code:

set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
set rs = Server.CreateObject("ADODB.Recordset")
conn.qGetUser p1,p2,rs
if rs(0) = "Administrator" OR rs(0) = "User" then
session("boolean") = "true"
End if
if Err.number <> 0 then
Response.Write(Err.number & ":" & Err.Description & "<br>")end if
on Error goto 0
conn.close
Set conn = nothing


ms access sql:

SELECT Type FROM Account WHERE username=[p1] AND password=[p2];


The problem that I am facing is that if I enter and invalid username or
password what happens is I get the following error:

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

How do I solve the problem?.


Eugene Anthony
 
B

Bob Barrows [MVP]

Eugene said:
asp code:

set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
set rs = Server.CreateObject("ADODB.Recordset")
conn.qGetUser p1,p2,rs
if rs(0) = "Administrator" OR rs(0) = "User" then
session("boolean") = "true"
End if
if Err.number <> 0 then
Response.Write(Err.number & ":" & Err.Description & "<br>")end if
on Error goto 0
conn.close
Set conn = nothing


ms access sql:

SELECT Type FROM Account WHERE username=[p1] AND password=[p2];


The problem that I am facing is that if I enter and invalid username
or password what happens is I get the following error:

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

How do I solve the problem?.
Never try to check the contents of a recordset without first determining
that it has records by checking its eof property:

conn.qGetUser p1,p2,rs
if not rs.eof then
if rs(0) = "Administrator" OR rs(0) = "User" then
session("boolean") = "true"
End if
etc.
end if
 
T

Turkbear

asp code:

set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
set rs = Server.CreateObject("ADODB.Recordset")
conn.qGetUser p1,p2,rs Inser
if rs(0) = "Administrator" OR rs(0) = "User" then
session("boolean") = "true"
End if
if Err.number <> 0 then
Response.Write(Err.number & ":" & Err.Description & "<br>")end if
on Error goto 0
conn.close
Set conn = nothing


ms access sql:

SELECT Type FROM Account WHERE username=[p1] AND password=[p2];


The problem that I am facing is that if I enter and invalid username or
password what happens is I get the following error:

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

How do I solve the problem?.


Eugene Anthony

That is expected behavior...No records were returned to the dataset so BOF or EOF is 'seen' by the code..

Place a test for those conditions BEFORE trying to access any of the returned data.
Your error trap expects data to be in the rs.
 
S

solomon_13000

When no records are returned does it mean rs is null?

What is the difference between

if rs.status = null then
.....code
end if

and

if not rs.eof then
....code
end if
 
S

solomon_13000

When no records are returned does it mean rs is null?

What is the difference between

if rs.status = null then
.....code
end if

and

if not rs.eof then
....code
end if
 
B

Bob Barrows [MVP]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

error handling 4
code execution 3
asp insert 11
username and password validation 10
paging error handling 1
Paging 3
ASP Access Recordset Paging 6
Return value 8

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top