ADO in global.asa

Discussion in 'ASP General' started by Mac Davis, Dec 30, 2003.

  1. Mac Davis

    Mac Davis Guest

    Is it possible to use ADO in global.asa?
    I simply want to creat a log of each visit to the site?

    Thanks,

    -dmd-
     
    Mac Davis, Dec 30, 2003
    #1
    1. Advertising

  2. Mac Davis

    Ray at Guest

    Yes. What do you want to, exactly? You can open an ADO connection, execute
    a query, close and destroy your connection in Session_onStart, for example,
    if you choose.

    Ray at work

    "Mac Davis" <> wrote in message
    news:...
    > Is it possible to use ADO in global.asa?
    > I simply want to creat a log of each visit to the site?
    >
    > Thanks,
    >
    > -dmd-
    >
    >
     
    Ray at, Dec 30, 2003
    #2
    1. Advertising

  3. Mac Davis

    Mac Davis Guest

    The follwing is in Session_Onstart
    I know the connectionstring is correct because it works on other pages.
    I simply want to add a record to do_userlog

    ---------------------------------------------------------------------
    dim TimeSt
    dim sq
    dim sqlstr

    sq = chr (39)
    TimeSt = now

    session ("connectionstring") = "Provider=SQLOLEDB.1; Data Source=xxxxx;
    Initial Catalog=xxxxx; User ID=xxxxx;Password=xxxxx"

    set objconn = server.createobject ("ADODB.connection")
    set objrec = server.createobject ("ADODB.recordset")

    objconn.connectionstring = session ("connectionstring")

    sqlstr = "insert into do_userlog (timdate, logid, password, viewed) values
    ("
    'sqlstr = sqlstr & sq & timest & sq & "," & sq & "0101150" & sq & "," & sq &
    "004650" & sq & "," & sq & "F" & sq & ")"

    sqlstr = "select * from do_events order by postdate desc"

    objconn.open
    objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly

    set objrec = nothing
    set objconn = nothing
    ----------------------------------------------------------------------------
    --
    The following error is returned
    ADODB.Recordset error '800a0bb9'

    Arguments are of the wrong type, are out of acceptable range, or are in
    conflict with one another.

    /LM/W3SVC/1002338185/Root/global.asa, line 48

    ----------------------------------------------------------------------------
    ---

    so, to simplify for troubleshooting I change sqlstr to sqlstr = "select *
    from do_events order by postdate desc"

    which works fine on other pages, and I receive exactly the same error.



    -dmd-






    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:%23AJf%...
    > Yes. What do you want to, exactly? You can open an ADO connection,

    execute
    > a query, close and destroy your connection in Session_onStart, for

    example,
    > if you choose.
    >
    > Ray at work
    >
    > "Mac Davis" <> wrote in message
    > news:...
    > > Is it possible to use ADO in global.asa?
    > > I simply want to creat a log of each visit to the site?
    > >
    > > Thanks,
    > >
    > > -dmd-
    > >
    > >

    >
    >
     
    Mac Davis, Dec 30, 2003
    #3
  4. Mac Davis

    Bob Barrows Guest

    Mac Davis wrote:
    > The follwing is in Session_Onstart
    > I know the connectionstring is correct because it works on other
    > pages.
    > I simply want to add a record to do_userlog
    >
    > ---------------------------------------------------------------------
    > objconn.open
    > objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly
    >
    > The following error is returned
    > ADODB.Recordset error '800a0bb9'
    >
    > Arguments are of the wrong type, are out of acceptable range, or are in
    > conflict with one another.


    This error means that you do not have the ado constants (adOpenStatic, etc.)
    defined on this page. You will either need to define them yourself (you can
    look up the Const statements in the adovbs.inc file), or use the method
    shown here:
    http://www.aspfaq.com/show.asp?id=2112

    HTH,
    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.
     
    Bob Barrows, Dec 30, 2003
    #4
  5. Mac Davis

    Ray at Guest

    Your first step would be to take this out of your onStart and put it in a
    normal page so you can debug it. Then, instead of executing your sqlstr
    query, response.Write it so you can see it. I think you may find that the
    result is:

    insert into do_userlog (timdate, logid, password, viewed) values(

    You have the rest of your sqlstr commented out (').

    Oh, wait, no, you're overwriting your first SQL query.

    Also, since you're doing an insert, don't create a recordset. Just insert.

    Also, did you define your adOpenStatic and adlockrEadOnly constants?

    Also, "password" is a reserved SQL word, so you should bracket it.

    Try this in a normal .asp file:

    ---------------------------------------------------------------------
    dim TimeSt
    dim sq
    dim sqlstr

    sq = chr (39)
    TimeSt = now

    session ("connectionstring") = "Provider=SQLOLEDB.1; Data
    Source=xxxxx;Initial Catalog=xxxxx; User ID=xxxxx;Password=xxxxx"
    sqlstr = "insert into do_userlog (timdate, logid, [password], viewed) values
    ("
    sqlstr = sqlstr & sq & timest & sq & "," & sq & "0101150" & sq & "," & sq &
    "004650" & sq & "," & sq & "F" & sq & ")"

    objconn.open session("connectionstring") ''careful
    'objconn.execute sqlstr
    RESPONSE.WRITE SQLSTR
    objconn.close
    set objconn = nothing
    ---------------------------------------------------------------------


    Ray at work










    "Mac Davis" <> wrote in message
    news:...
    > The follwing is in Session_Onstart
    > I know the connectionstring is correct because it works on other pages.
    > I simply want to add a record to do_userlog
    >
    > ---------------------------------------------------------------------
    > dim TimeSt
    > dim sq
    > dim sqlstr
    >
    > sq = chr (39)
    > TimeSt = now
    >
    > session ("connectionstring") = "Provider=SQLOLEDB.1; Data Source=xxxxx;
    > Initial Catalog=xxxxx; User ID=xxxxx;Password=xxxxx"
    >
    > set objconn = server.createobject ("ADODB.connection")
    > set objrec = server.createobject ("ADODB.recordset")
    >
    > objconn.connectionstring = session ("connectionstring")
    >
    > sqlstr = "insert into do_userlog (timdate, logid, password, viewed) values
    > ("
    > 'sqlstr = sqlstr & sq & timest & sq & "," & sq & "0101150" & sq & "," & sq

    &
    > "004650" & sq & "," & sq & "F" & sq & ")"
    >
    > sqlstr = "select * from do_events order by postdate desc"
    >
    > objconn.open
    > objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly
    >
    > set objrec = nothing
    > set objconn = nothing
    > --------------------------------------------------------------------------

    --
    > --
    > The following error is returned
    > ADODB.Recordset error '800a0bb9'
    >
    > Arguments are of the wrong type, are out of acceptable range, or are in
    > conflict with one another.
    >
    > /LM/W3SVC/1002338185/Root/global.asa, line 48
    >
    > --------------------------------------------------------------------------

    --
    > ---
    >
    > so, to simplify for troubleshooting I change sqlstr to sqlstr = "select

    *
    > from do_events order by postdate desc"
    >
    > which works fine on other pages, and I receive exactly the same error.
    >
    >
    >
    > -dmd-
    >
    >
    >
    >
    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:%23AJf%...
    > > Yes. What do you want to, exactly? You can open an ADO connection,

    > execute
    > > a query, close and destroy your connection in Session_onStart, for

    > example,
    > > if you choose.
    > >
    > > Ray at work
    > >
    > > "Mac Davis" <> wrote in message
    > > news:...
    > > > Is it possible to use ADO in global.asa?
    > > > I simply want to creat a log of each visit to the site?
    > > >
    > > > Thanks,
    > > >
    > > > -dmd-
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ray at, Dec 30, 2003
    #5
  6. Mac Davis

    Mac Davis Guest

    Thanks Bob,

    Added the constants and all is well.

    If only the obvious were obvious I obviously wouldn't have to ask so many
    questions.

    -dmd-




    "Bob Barrows" <> wrote in message
    news:...
    > Mac Davis wrote:
    > > The follwing is in Session_Onstart
    > > I know the connectionstring is correct because it works on other
    > > pages.
    > > I simply want to add a record to do_userlog
    > >
    > > ---------------------------------------------------------------------
    > > objconn.open
    > > objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly
    > >
    > > The following error is returned
    > > ADODB.Recordset error '800a0bb9'
    > >
    > > Arguments are of the wrong type, are out of acceptable range, or are in
    > > conflict with one another.

    >
    > This error means that you do not have the ado constants (adOpenStatic,

    etc.)
    > defined on this page. You will either need to define them yourself (you

    can
    > look up the Const statements in the adovbs.inc file), or use the method
    > shown here:
    > http://www.aspfaq.com/show.asp?id=2112
    >
    > HTH,
    > 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.
    >
    >
     
    Mac Davis, Dec 30, 2003
    #6
  7. Mac Davis

    Mac Davis Guest

    Okay, now one more question.
    The default page for this site is a frameset page with three .asp pages in
    the frame.

    What is happening now when someone visits the site is thatI get three logins
    entries in the table for the initial visit. Is this because the three asp
    pages are in effect accessed simultaneously?

    What I want is one entry in the table every time someone hits the site. I
    was doing this with a session variable. Seemed like doing it through the
    global.asa was cleaner. any thoughts?

    Thanks again

    -dmd-

    "Bob Barrows" <> wrote in message
    news:...
    > Mac Davis wrote:
    > > The follwing is in Session_Onstart
    > > I know the connectionstring is correct because it works on other
    > > pages.
    > > I simply want to add a record to do_userlog
    > >
    > > ---------------------------------------------------------------------
    > > objconn.open
    > > objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly
    > >
    > > The following error is returned
    > > ADODB.Recordset error '800a0bb9'
    > >
    > > Arguments are of the wrong type, are out of acceptable range, or are in
    > > conflict with one another.

    >
    > This error means that you do not have the ado constants (adOpenStatic,

    etc.)
    > defined on this page. You will either need to define them yourself (you

    can
    > look up the Const statements in the adovbs.inc file), or use the method
    > shown here:
    > http://www.aspfaq.com/show.asp?id=2112
    >
    > HTH,
    > 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.
    >
    >
     
    Mac Davis, Dec 31, 2003
    #7
  8. Mac Davis

    Mac Davis Guest

    Thanks,

    My problem was that I was referring to the constants in the adovbs.inc file
    and the file was not included.
    I added the constants to global.asa and it works fine.

    -dmd-


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:%23AJf%...
    > Yes. What do you want to, exactly? You can open an ADO connection,

    execute
    > a query, close and destroy your connection in Session_onStart, for

    example,
    > if you choose.
    >
    > Ray at work
    >
    > "Mac Davis" <> wrote in message
    > news:...
    > > Is it possible to use ADO in global.asa?
    > > I simply want to creat a log of each visit to the site?
    > >
    > > Thanks,
    > >
    > > -dmd-
    > >
    > >

    >
    >
     
    Mac Davis, Dec 31, 2003
    #8
    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. Wayne
    Replies:
    2
    Views:
    476
    Wayne
    Nov 11, 2003
  2. nita
    Replies:
    1
    Views:
    879
    Saravana
    Nov 20, 2004
  3. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    465
    Kevin Spencer
    Dec 17, 2004
  4. Replies:
    0
    Views:
    1,320
  5. Navin
    Replies:
    1
    Views:
    702
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page