0x800A0E7D error--don't get it

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

    0x800A0E7D error--don't get it

    I had some text links at the top of all my pages (in one include file),
    which worked just fine. But I was asked to make it so that people in a
    certain department, (this is an Intranet app) would see a particular link
    that nobody else would. You'd find their name by getting their network
    logon. This worked fine on all my pages, but for some reason, on one page,
    it gives me an error. First, the error:

    Error Type:
    ADODB.Recordset (0x800A0E7D)
    The connection cannot be used to perform this operation. It is either closed
    or invalid in this context.
    /includes/header.inc, line 32

    Before we go any farther, please note that I went to ASPFAQ.com, and
    couldn't find an answer there which fit my situation. The article that
    seemed to have the best shot for me was
    http://www.aspfaq.com/show.asp?id=2191, but no dice.

    Anyway, here's my code:

    'this first line is there because when you get the network logon name, it is
    prefixed by the domain name and a backslash. Since the db I am pulling data
    from has only the logon name, I had to get rid of the first part:

    strLogon= Replace(Request .ServerVariable s("LOGON_USER") ,"domainname\", "")
    Set RSLogon = Server.CreateOb ject("ADODB.Rec ordset")
    strSQL = "SELECT EmployeeID, DepartmentID "
    strSQL = strSQL & "FROM Employee "
    strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
    'this next line is the infamous line 32
    RSLogon.Open strSQL, objConnection
    objConnection.e xecute strSQL,,&h00000 080

    strDepartmentID = RSLogon("Depart mentID")
    strEmployeeID = RSLogon("Employ eeID")
    RSLogon.Close
    Set RSLogon = Nothing

    If strDepartmentID = "9" then%>
    do some stuff
    End if



    Keep in mind that this code works fine on other pages, just not this one. In
    fact, it works when you first bring this page up, but it does submit to
    itself, and when it does, you should see a "thank-you"-type message, but get
    the error instead. But in the code at the top of the page, before it decides
    if it's the original page or the repost, I have the same includes which
    establish the same db connection. I mention this because the first thing
    you look for is the difference between the pages that work and the ones that
    don't. In fact, this code is in an include file which is used on all pages,
    and that rules out any differences in code, you'd think.



  • Mark Schupp

    #2
    Re: 0x800A0E7D error--don't get it

    First, you do not seem to be opening a database connection.
    Second, you seem to be executing the query twice.
    Third, you are not checking to see if the query returns anything before
    attempting to access column data.
    Fourth, you should not explicitly create a recordset for that type of query.
    Try:

    strSQL = "SELECT EmployeeID, DepartmentID "
    strSQL = strSQL & "FROM Employee "
    strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
    Set RSLogon = objConnection.e xecute(strSQL,, 1)
    If Not RSLogon.EOF Then
    strDepartmentID = RSLogon("Depart mentID")
    strEmployeeID = RSLogon("Employ eeID")
    End If
    RSLogon.Close
    Set RSLogon = Nothing


    --
    Mark Schupp
    Head of Development
    Integrity eLearning



    "middletree " <middletree@hto mail.com> wrote in message
    news:uh55hXX1DH A.3436@tk2msftn gp13.phx.gbl...[color=blue]
    > I had some text links at the top of all my pages (in one include file),
    > which worked just fine. But I was asked to make it so that people in a
    > certain department, (this is an Intranet app) would see a particular link
    > that nobody else would. You'd find their name by getting their network
    > logon. This worked fine on all my pages, but for some reason, on one[/color]
    page,[color=blue]
    > it gives me an error. First, the error:
    >
    > Error Type:
    > ADODB.Recordset (0x800A0E7D)
    > The connection cannot be used to perform this operation. It is either[/color]
    closed[color=blue]
    > or invalid in this context.
    > /includes/header.inc, line 32
    >
    > Before we go any farther, please note that I went to ASPFAQ.com, and
    > couldn't find an answer there which fit my situation. The article that
    > seemed to have the best shot for me was
    > http://www.aspfaq.com/show.asp?id=2191, but no dice.
    >
    > Anyway, here's my code:
    >
    > 'this first line is there because when you get the network logon name, it[/color]
    is[color=blue]
    > prefixed by the domain name and a backslash. Since the db I am pulling[/color]
    data[color=blue]
    > from has only the logon name, I had to get rid of the first part:
    >
    > strLogon= Replace(Request .ServerVariable s("LOGON_USER") ,"domainname\", "")[/color]
    [color=blue]
    > Set RSLogon = Server.CreateOb ject("ADODB.Rec ordset")
    > strSQL = "SELECT EmployeeID, DepartmentID "
    > strSQL = strSQL & "FROM Employee "
    > strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
    > 'this next line is the infamous line 32
    > RSLogon.Open strSQL, objConnection
    > objConnection.e xecute strSQL,,&h00000 080
    >
    > strDepartmentID = RSLogon("Depart mentID")
    > strEmployeeID = RSLogon("Employ eeID")
    > RSLogon.Close
    > Set RSLogon = Nothing
    >
    > If strDepartmentID = "9" then%>
    > do some stuff
    > End if
    >
    >
    >
    > Keep in mind that this code works fine on other pages, just not this one.[/color]
    In[color=blue]
    > fact, it works when you first bring this page up, but it does submit to
    > itself, and when it does, you should see a "thank-you"-type message, but[/color]
    get[color=blue]
    > the error instead. But in the code at the top of the page, before it[/color]
    decides[color=blue]
    > if it's the original page or the repost, I have the same includes which
    > establish the same db connection. I mention this because the first thing
    > you look for is the difference between the pages that work and the ones[/color]
    that[color=blue]
    > don't. In fact, this code is in an include file which is used on all[/color]
    pages,[color=blue]
    > and that rules out any differences in code, you'd think.
    >
    >
    >[/color]


    Comment

    • middletree

      #3
      Re: 0x800A0E7D error--don't get it

      OK, I'll try it out. Thanks.

      I am not sure why I shouldn't use a recordset, though.

      I'm also not sure why this works on every other page which uses this same
      exact code.


      "Mark Schupp" <mschupp@ielear ning.com> wrote in message
      news:epnIAgX1DH A.540@tk2msftng p13.phx.gbl...[color=blue]
      > First, you do not seem to be opening a database connection.
      > Second, you seem to be executing the query twice.
      > Third, you are not checking to see if the query returns anything before
      > attempting to access column data.
      > Fourth, you should not explicitly create a recordset for that type of[/color]
      query.[color=blue]
      > Try:
      >
      > strSQL = "SELECT EmployeeID, DepartmentID "
      > strSQL = strSQL & "FROM Employee "
      > strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
      > Set RSLogon = objConnection.e xecute(strSQL,, 1)
      > If Not RSLogon.EOF Then
      > strDepartmentID = RSLogon("Depart mentID")
      > strEmployeeID = RSLogon("Employ eeID")
      > End If
      > RSLogon.Close
      > Set RSLogon = Nothing
      >
      >
      > --
      > Mark Schupp
      > Head of Development
      > Integrity eLearning
      > www.ielearning.com
      >
      >
      > "middletree " <middletree@hto mail.com> wrote in message
      > news:uh55hXX1DH A.3436@tk2msftn gp13.phx.gbl...[color=green]
      > > I had some text links at the top of all my pages (in one include file),
      > > which worked just fine. But I was asked to make it so that people in a
      > > certain department, (this is an Intranet app) would see a particular[/color][/color]
      link[color=blue][color=green]
      > > that nobody else would. You'd find their name by getting their network
      > > logon. This worked fine on all my pages, but for some reason, on one[/color]
      > page,[color=green]
      > > it gives me an error. First, the error:
      > >
      > > Error Type:
      > > ADODB.Recordset (0x800A0E7D)
      > > The connection cannot be used to perform this operation. It is either[/color]
      > closed[color=green]
      > > or invalid in this context.
      > > /includes/header.inc, line 32
      > >
      > > Before we go any farther, please note that I went to ASPFAQ.com, and
      > > couldn't find an answer there which fit my situation. The article that
      > > seemed to have the best shot for me was
      > > http://www.aspfaq.com/show.asp?id=2191, but no dice.
      > >
      > > Anyway, here's my code:
      > >
      > > 'this first line is there because when you get the network logon name,[/color][/color]
      it[color=blue]
      > is[color=green]
      > > prefixed by the domain name and a backslash. Since the db I am pulling[/color]
      > data[color=green]
      > > from has only the logon name, I had to get rid of the first part:
      > >
      > > strLogon=[/color][/color]
      Replace(Request .ServerVariable s("LOGON_USER") ,"domainname\", "")[color=blue]
      >[color=green]
      > > Set RSLogon = Server.CreateOb ject("ADODB.Rec ordset")
      > > strSQL = "SELECT EmployeeID, DepartmentID "
      > > strSQL = strSQL & "FROM Employee "
      > > strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
      > > 'this next line is the infamous line 32
      > > RSLogon.Open strSQL, objConnection
      > > objConnection.e xecute strSQL,,&h00000 080
      > >
      > > strDepartmentID = RSLogon("Depart mentID")
      > > strEmployeeID = RSLogon("Employ eeID")
      > > RSLogon.Close
      > > Set RSLogon = Nothing
      > >
      > > If strDepartmentID = "9" then%>
      > > do some stuff
      > > End if
      > >
      > >
      > >
      > > Keep in mind that this code works fine on other pages, just not this[/color][/color]
      one.[color=blue]
      > In[color=green]
      > > fact, it works when you first bring this page up, but it does submit to
      > > itself, and when it does, you should see a "thank-you"-type message, but[/color]
      > get[color=green]
      > > the error instead. But in the code at the top of the page, before it[/color]
      > decides[color=green]
      > > if it's the original page or the repost, I have the same includes which
      > > establish the same db connection. I mention this because the first[/color][/color]
      thing[color=blue][color=green]
      > > you look for is the difference between the pages that work and the ones[/color]
      > that[color=green]
      > > don't. In fact, this code is in an include file which is used on all[/color]
      > pages,[color=green]
      > > and that rules out any differences in code, you'd think.
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Bob Barrows

        #4
        Re: 0x800A0E7D error--don't get it

        Mark Schupp wrote:[color=blue]
        > First, you do not seem to be opening a database connection.[/color]

        Right, I'm not sure of this as well. Middletree, have you simply not shown
        us the code where you opened the objConnection object?
        [color=blue]
        > Second, you seem to be executing the query twice.[/color]

        That is true. Middletree, was one of these staements supposed to be
        commented out?
        RSLogon.Open strSQL, objConnection
        objConnection.e xecute strSQL,,&h00000 080

        The second statement is simply not correct. It should not be there. That is
        the statement that should be used to execute a non-records-returning query.
        Actually, I prefer to explicitly set the Options argument in the Open
        statement (it's got nothing to do with your problem)

        RSLogon.Open strSQL, objConnection,, ,1 '1 = adCmdText
        [color=blue]
        > Third, you are not checking to see if the query returns anything
        > before attempting to access column data.[/color]

        Right. Always check the recordset's EOF property before attempting to access
        any of its data.
        [color=blue]
        > Fourth, you should not explicitly create a recordset for that type of
        > query. Try:[/color]

        Why not? What possible difference can that make? Whether you explicitly
        create a recordset and then call its Open method, or use Execute to tell ADO
        to create a recordset and open it should make absolutely no difference. I
        hate when this advice is given because:
        1. It's a waste of time - it's never the root of the problem
        2. It confuses newcomers who think you are telling them not to use a
        recordset - we're here to help people, not to further confuse them.

        Bob Barrows
        --
        Microsoft MVP -- ASP/ASP.NET
        Please reply to the newsgroup. The email account listed in my From
        header is my spam trap, so I don't check it very often. You will get a
        quicker response by posting to the newsgroup.


        Comment

        • Bob Barrows

          #5
          Re: 0x800A0E7D error--don't get it

          middletree wrote:[color=blue]
          > OK, I'll try it out. Thanks.
          >
          > I am not sure why I shouldn't use a recordset, though.
          >[/color]
          To Mark: See? He thought you were telling him not to use a recordset!

          middletree, just to clarify: you are always using a recordset, even when you
          use Execute (unless you use that &h00000080 constant (adExecuteNoRec ords) to
          tell ADO not to create a recordset).

          FWIW, I have never seen a problem solved by switching from

          Set rs=server.creat eobject("adodb. recordset")
          rs.open ...

          to

          set rs = conn.execute(.. .)

          I have seen cases where problems were masked by the switch, but the root
          problem was never addressed because the switch made everything "work".

          Bob Barrows
          --
          Microsoft MVP -- ASP/ASP.NET
          Please reply to the newsgroup. The email account listed in my From
          header is my spam trap, so I don't check it very often. You will get a
          quicker response by posting to the newsgroup.


          Comment

          • middletree

            #6
            Re: 0x800A0E7D error--don't get it

            Bob:

            As always, thanks for you help. I have comments below:

            "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
            news:OYXaD7e1DH A.1700@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Mark Schupp wrote:[color=green]
            > > First, you do not seem to be opening a database connection.[/color]
            >
            > Right, I'm not sure of this as well. Middletree, have you simply not shown
            > us the code where you opened the objConnection object?[/color]

            Well, I have an include file for every page which establishes the
            connection. But that's on the pages where this works, and the one where it
            doesn't.
            Anyway, here's that code:
            Dim strDBConnection
            strDBConnection = _
            "Provider=SQLOL EDB;" & _
            "Persist Security Info=False;" & _
            "Data Source=xxxxxx;" & _
            "User ID=xxxxx;" & _
            "Password=xxxxx ;" & _
            "Database=xxxxx x;"

            Dim objConnection
            Set objConnection = Server.CreateOb ject("ADODB.Con nection")
            objConnection.O pen strDBConnection
            [color=blue]
            >[color=green]
            > > Second, you seem to be executing the query twice.[/color]
            >
            > That is true. Middletree, was one of these statements supposed to be
            > commented out?
            > RSLogon.Open strSQL, objConnection
            > objConnection.e xecute strSQL,,&h00000 080
            >[/color]

            What happened there was I tried a million things before being so exhausted
            by the whole thing that I posted a question.
            Here's the code which is currently in use, and which works on all pages
            except the one. Note that the Recordset is simply called RS, not RSLogon,
            as the use of a rs name that was used elsewhere was one of many things I
            thought might be a conflict.
            (I replaced our network domain name with x's)

            strLogon= Replace(Request .ServerVariable s("LOGON_USER") ,"xxxxx\","" )

            Set RS = Server.CreateOb ject("ADODB.Rec ordset")
            strSQL = "SELECT EmployeeID, DepartmentID "
            strSQL = strSQL & "FROM Employee "
            strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
            RS.Open strSQL, objConnection

            strDepartmentID = rs("DepartmentI D")
            strEmployeeID = rs("EmployeeID" )
            rs.Close
            Set rs = Nothing

            If strDepartmentID = "9" then%>
            <img src="images/spacer.gif" width="22" border="0">
            <a href="DisplaySo rtableTickets.a sp?selectTSE=<% =strEmployeeID% >">
            <span class="cellsmal l">Your open Tickets</span></a>
            <%Else
            end if


            [color=blue]
            > The second statement is simply not correct. It should not be there. That[/color]
            is[color=blue]
            > the statement that should be used to execute a non-records-returning[/color]
            query.[color=blue]
            > Actually, I prefer to explicitly set the Options argument in the Open
            > statement (it's got nothing to do with your problem)
            >
            > RSLogon.Open strSQL, objConnection,, ,1 '1 = adCmdText
            >[color=green]
            > > Third, you are not checking to see if the query returns anything
            > > before attempting to access column data.[/color]
            >
            > Right. Always check the recordset's EOF property before attempting to[/color]
            access[color=blue]
            > any of its data.
            >[/color]

            Noted. thanks.


            Comment

            • Mark Schupp

              #7
              Re: 0x800A0E7D error--don't get it

              > > Fourth, you should not explicitly create a recordset for that type of[color=blue][color=green]
              > > query. Try:[/color]
              >
              > Why not? What possible difference can that make? Whether you explicitly
              > create a recordset and then call its Open method, or use Execute to tell[/color]
              ADO[color=blue]
              > to create a recordset and open it should make absolutely no difference. I
              > hate when this advice is given because:
              > 1. It's a waste of time - it's never the root of the problem
              > 2. It confuses newcomers who think you are telling them not to use a
              > recordset - we're here to help people, not to further confuse them.[/color]

              2 lines of code = 2 chances to mess up
              1 line of code = 1 chance.

              I probably would not have bothered with that bit of advice except that he
              use both rs.open and conn.execute on the same SQL statement which indicates
              a bit of confusion about recordset usage anyway. My guess as to his actual
              problem is that he is not getting any records back. Since he was not
              checking for EOF this would cause an error.

              --
              Mark Schupp
              Head of Development
              Integrity eLearning



              "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
              news:OYXaD7e1DH A.1700@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Mark Schupp wrote:[color=green]
              > > First, you do not seem to be opening a database connection.[/color]
              >
              > Right, I'm not sure of this as well. Middletree, have you simply not shown
              > us the code where you opened the objConnection object?
              >[color=green]
              > > Second, you seem to be executing the query twice.[/color]
              >
              > That is true. Middletree, was one of these staements supposed to be
              > commented out?
              > RSLogon.Open strSQL, objConnection
              > objConnection.e xecute strSQL,,&h00000 080
              >
              > The second statement is simply not correct. It should not be there. That[/color]
              is[color=blue]
              > the statement that should be used to execute a non-records-returning[/color]
              query.[color=blue]
              > Actually, I prefer to explicitly set the Options argument in the Open
              > statement (it's got nothing to do with your problem)
              >
              > RSLogon.Open strSQL, objConnection,, ,1 '1 = adCmdText
              >[color=green]
              > > Third, you are not checking to see if the query returns anything
              > > before attempting to access column data.[/color]
              >
              > Right. Always check the recordset's EOF property before attempting to[/color]
              access[color=blue]
              > any of its data.
              >[color=green]
              > > Fourth, you should not explicitly create a recordset for that type of
              > > query. Try:[/color]
              >
              > Why not? What possible difference can that make? Whether you explicitly
              > create a recordset and then call its Open method, or use Execute to tell[/color]
              ADO[color=blue]
              > to create a recordset and open it should make absolutely no difference. I
              > hate when this advice is given because:
              > 1. It's a waste of time - it's never the root of the problem
              > 2. It confuses newcomers who think you are telling them not to use a
              > recordset - we're here to help people, not to further confuse them.
              >
              > Bob Barrows
              > --
              > Microsoft MVP -- ASP/ASP.NET
              > Please reply to the newsgroup. The email account listed in my From
              > header is my spam trap, so I don't check it very often. You will get a
              > quicker response by posting to the newsgroup.
              >
              >[/color]


              Comment

              • middletree

                #8
                Re: 0x800A0E7D error--don't get it

                "Mark Schupp" <mschupp@ielear ning.com> wrote in message
                news:e36OIrg1DH A.1676@TK2MSFTN GP12.phx.gbl...[color=blue]
                >
                > I probably would not have bothered with that bit of advice except that he
                > use both rs.open and conn.execute on the same SQL statement which[/color]
                indicates[color=blue]
                > a bit of confusion about recordset usage anyway. My guess as to his actual
                > problem is that he is not getting any records back. Since he was not
                > checking for EOF this would cause an error.[/color]


                You are correct when you say that I am confused about recordsets. For some
                reason, in 4 years of doing ASP (although not 40 hours per week), I have not
                gotten connection strings, recordsets, anything related to that sort of
                thing. Not sure why. I'm not dumb. 2 college degrees, won the spelling bee
                in 5th grade, etc.

                But it (lack of understanding about rs's and connections) usually doesn't
                pose a problem, as I have code I can re-use. But I cannot emphasize enough
                that what you saw of my code was the last in a chain of trying a million
                different things. I can assure you that most of the day, I wasn't trying to
                connect twice.


                Comment

                • middletree

                  #9
                  Resolution! : 0x800A0E7D error--don't get it

                  Well, I put in Mark's code below, and still got an "Object Required" error.
                  Only on that one page. Not sure why. But since the line it pointed to was
                  the objConnection.e xecute, I simply pasted in this code from the db
                  connection include file that I have at the top of all pages:

                  Set objConnection = Server.CreateOb ject("ADODB.Con nection")
                  objConnection.O pen strDBConnection


                  I have no idea why this works, but it does. Doesn't seem to affect any
                  other pages negatively, so I'm thankful for that. But it shouldn't have been
                  a problem on this one page, as the include file is here on this page, as
                  well, so objConnection should be there. I have no idea why this fixed it,
                  but am not up for spending any more time on this, as I have other fish to
                  fry.

                  thanks for your help, guys!

                  James W



                  "Mark Schupp" <mschupp@ielear ning.com> wrote in message
                  news:epnIAgX1DH A.540@tk2msftng p13.phx.gbl...[color=blue]
                  > First, you do not seem to be opening a database connection.
                  > Second, you seem to be executing the query twice.
                  > Third, you are not checking to see if the query returns anything before
                  > attempting to access column data.
                  > Fourth, you should not explicitly create a recordset for that type of[/color]
                  query.[color=blue]
                  > Try:
                  >
                  > strSQL = "SELECT EmployeeID, DepartmentID "
                  > strSQL = strSQL & "FROM Employee "
                  > strSQL = strSQL & "WHERE NetworkID = '"&strLogon& "'"
                  > Set RSLogon = objConnection.e xecute(strSQL,, 1)
                  > If Not RSLogon.EOF Then
                  > strDepartmentID = RSLogon("Depart mentID")
                  > strEmployeeID = RSLogon("Employ eeID")
                  > End If
                  > RSLogon.Close
                  > Set RSLogon = Nothing
                  >
                  >
                  > --
                  > Mark Schupp
                  > Head of Development
                  > Integrity eLearning
                  > www.ielearning.com
                  >
                  >[/color]


                  Comment

                  Working...