recordset

Discussion in 'ASP General' started by Eugene Anthony, Jun 23, 2006.

  1. 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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Jun 23, 2006
    #1
    1. Advertising

  2. Eugene Anthony wrote:
    > 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


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jun 23, 2006
    #2
    1. Advertising

  3. Eugene Anthony

    Turkbear Guest

    On Fri, 23 Jun 2006 10:39:03 -0700, Eugene Anthony <> wrote:

    >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
    >
    >*** Sent via Developersdex http://www.developersdex.com ***


    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.
     
    Turkbear, Jun 23, 2006
    #3
  4. 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



    Eugene Anthony wrote:
    > 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
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    solomon_13000, Jun 24, 2006
    #4
  5. 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



    Eugene Anthony wrote:
    > 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
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    solomon_13000, Jun 24, 2006
    #5
  6. solomon_13000 wrote:
    > When no records are returned does it mean rs is null?


    No
    >
    > What is the difference between
    >
    > if rs.status = null then
    > ....code
    > end if
    >


    status should not be null. status has nothing to do with whether or not the
    recordset contains records:
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdprostatus.asp

    > and
    >
    > if not rs.eof then
    > ...code
    > end if
    >

    http://msdn.microsoft.com/library/en-us/ado270/htm/mdprobof.asp

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jun 24, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vikas Yadav
    Replies:
    0
    Views:
    1,142
    Vikas Yadav
    Sep 9, 2003
  2. gary artim

    recordset error/perl messages

    gary artim, Feb 6, 2004, in forum: Perl
    Replies:
    0
    Views:
    501
    gary artim
    Feb 6, 2004
  3. Bob
    Replies:
    0
    Views:
    409
  4. NAIME ESTEVES

    RECORDSET

    NAIME ESTEVES, Jul 10, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    563
    NAIME ESTEVES
    Jul 11, 2003
  5. Hung Huynh
    Replies:
    8
    Views:
    329
    Bob Barrows
    Sep 24, 2003
Loading...

Share This Page