recordset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eugene Anthony

    recordset

    asp code:

    set conn = Server.CreateOb ject("ADODB.Con nection")
    conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    Server.MapPath( "/db/upload/stelladb.mdb") & ";"
    set rs = Server.CreateOb ject("ADODB.Rec ordset")
    conn.qGetUser p1,p2,rs
    if rs(0) = "Administra tor" OR rs(0) = "User" then
    session("boolea n") = "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:Eith er 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 ***
  • Bob Barrows [MVP]

    #2
    Re: recordset

    Eugene Anthony wrote:[color=blue]
    > asp code:
    >
    > set conn = Server.CreateOb ject("ADODB.Con nection")
    > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
    > set rs = Server.CreateOb ject("ADODB.Rec ordset")
    > conn.qGetUser p1,p2,rs
    > if rs(0) = "Administra tor" OR rs(0) = "User" then
    > session("boolea n") = "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:Eith er BOF or EOF is True, or the current record has been
    > deleted. Requested operation requires a current record"
    >
    > How do I solve the problem?.
    >
    >[/color]
    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) = "Administra tor" OR rs(0) = "User" then
    session("boolea n") = "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"


    Comment

    • Turkbear

      #3
      Re: recordset

      On Fri, 23 Jun 2006 10:39:03 -0700, Eugene Anthony <solomon_13000@ yahoo.com> wrote:
      [color=blue]
      >asp code:
      >
      >set conn = Server.CreateOb ject("ADODB.Con nection")
      >conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
      >Server.MapPath ("/db/upload/stelladb.mdb") & ";"
      >set rs = Server.CreateOb ject("ADODB.Rec ordset")
      >conn.qGetUse r p1,p2,rs Inser
      >if rs(0) = "Administra tor" OR rs(0) = "User" then
      > session("boolea n") = "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:Eith er 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 ***[/color]

      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.


      Comment

      • solomon_13000

        #4
        Re: recordset

        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:[color=blue]
        > asp code:
        >
        > set conn = Server.CreateOb ject("ADODB.Con nection")
        > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
        > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
        > set rs = Server.CreateOb ject("ADODB.Rec ordset")
        > conn.qGetUser p1,p2,rs
        > if rs(0) = "Administra tor" OR rs(0) = "User" then
        > session("boolea n") = "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:Eith er 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 ***[/color]

        Comment

        • solomon_13000

          #5
          Re: recordset

          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:[color=blue]
          > asp code:
          >
          > set conn = Server.CreateOb ject("ADODB.Con nection")
          > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
          > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
          > set rs = Server.CreateOb ject("ADODB.Rec ordset")
          > conn.qGetUser p1,p2,rs
          > if rs(0) = "Administra tor" OR rs(0) = "User" then
          > session("boolea n") = "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:Eith er 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 ***[/color]

          Comment

          • Bob Barrows [MVP]

            #6
            Re: recordset

            solomon_13000 wrote:[color=blue]
            > When no records are returned does it mean rs is null?[/color]

            No[color=blue]
            >
            > What is the difference between
            >
            > if rs.status = null then
            > ....code
            > end if
            >[/color]

            status should not be null. status has nothing to do with whether or not the
            recordset contains records:
            Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.

            [color=blue]
            > and
            >
            > if not rs.eof then
            > ...code
            > end if
            >[/color]
            Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.


            --
            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"


            Comment

            Working...