Global asa

I want to use the gobal.asa file: -


the error:-

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/lukegriffiths110/login.asp, line 26


The code:-


<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
      '      The connection string to the mdb.
      conn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & server.MapPath ("test.mdb") & ";Uid=Admin;Pwd=;"

End Sub

Sub Session_OnEnd
      set conn = Server.CreateObject ("ADODB.Connection")
      conn.Open Application("connString")
      '      Update the record when the user logout and write the logout time plus it sets the user as OFFLINE.
      query = "UPDATE User_LogTime SET Logout_Time=#" & now() & "#, offline=True WHERE offline=False AND SID=" & Session.SessionID & " AND user_id=" & Session("member")
      conn.Execute (query)
      conn.Close
      set conn = Nothing      
End Sub

</SCRIPT>
lukegriffiths110Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kevp75Commented:
change this:
Sub Application_OnStart
     '     The connection string to the mdb.
     conn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & server.MapPath ("test.mdb") & ";Uid=Admin;Pwd=;"

End Sub

to:

Sub Application_OnStart
     '     The connection string to the mdb.
     Application("connString") =  "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & server.MapPath ("test.mdb") & ";Uid=Admin;Pwd=;"

End Sub
lukegriffiths110Author Commented:
Sorry I have checked and it doesn't look like there was a problem with global but with login.asp.

the error:-

Script error detected at line 48.
Source line: conn.Execute ("UPDATE User_LogTime SET offline=True WHERE offline=False AND user_id=" & session("member"))

the code is:-


<%@ Language=VBScript %>
<% Response.Buffer = true %>
<!--#include file="header.asp"-->

<br>
<center>
<font size=4 color=DarkRed><b>Members login</b></font>
<br><br>

<%

      UserName = Request.Form ("UserName")
      Password = Request.Form ("Password")
      
      if UserName<>"" then
            if Password<>"" then
                  set conn = server.CreateObject ("ADODB.Connection")      
                  conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("test.mdb")
                  query = "SELECT Id FROM Members WHERE UserName='" & UserName & "' AND Password='" & Password & "'"
                  set rs = conn.Execute (query)
            
                  '      Check if the user and password are valid
                  if rs.eof then
                        ' There is no record to match the UserName and Password
                        Response.Write "<p class=errmsg>Invalid user and password!</p>"
                        conn.Close
                  else
                        ' User login ok and set the user_id value from the Members table in a session variable
                        Session("member") = rs("Id")
                        rs.close
                        set rs =  nothing
                        
                        '      Modify all the records from the User_LogTime corresponding to this user that were not closed properly when the user previously logout.
                        conn.Execute ("UPDATE User_LogTime SET offline=True WHERE offline=False AND user_id=" & session("member"))
                        
                        '      Insert a new record in the User_LogTime table with the user_id, Session ID and the login time.
                        query = "INSERT INTO User_LogTime (user_id, SID, Login_Time) VALUES (" & Session("member") & "," & Session.SessionID & ",#" & now() & "#)"
                        conn.Execute (query)
                        
                        conn.close
                        set conn = nothing
                        
                        Response.Redirect "home.asp"
                  end if      
            else
                  Response.Write "<p class=errmsg>Please fill both fields.</p>"
            end if
      end if
      
%>

<form action=login.asp method=post id=form1 name=form1>
<table>
<tr>
      <td class=fieldlabel>
        User Name
      </td>
      <td>
        <input type="text" name='UserName' class=defaultsmall>
      </td>
</tr>
<tr>
      <td class=fieldlabel>
      Password
    </td>
    <td>
      <input type=password name='Password' class=defaultsmall>
    </td>
</tr>
<tr>
      <td>&nbsp;</td>
      <td><input type=submit value="Log me in!" name=submit1 class=defaultsmall></td>
</tr>
</table>
</form>
kevp75Commented:
ok...let's see if we can work this out.
First thing I would do is move you conn.close, and set conn=nothing to the line above your last 2 end if's

Q4U:Are you using Baby Server?  Is there an error code that it gives out?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

kevp75Commented:
p.s.  you still shoul make that chagne in global.asa  (this way your connection isn't constantly open)
lukegriffiths110Author Commented:
I am using a baby server i have given the error on the top of the code.
kevp75Commented:
ok
Comment from kevp75
Date: 03/30/2006 09:44AM PST
 Your Comment  


ok...let's see if we can work this out.
First thing I would do is move you conn.close, and set conn=nothing to the line above your last 2 end if's
 
also....you should really make that change in global.asa.  That is a huge performance hit keeping that connection open all the time.

after you make the change, change this line in login.asp:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("test.mdb")

to:
conn.Open Application("connString")


after these changes, please test it out

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lukegriffiths110Author Commented:
I have made the change to the global.asa and have changed code to conn.Open Application("connString"). But am unsure about moving you conn.close, and set conn=nothing
lukegriffiths110Author Commented:
The error is now:-

Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'
lukegriffiths110Author Commented:
The application i am trying to get working is: -

http://www.codeproject.com/asp/user_logtime.asp

Could you look at it and sse if it is useable.
kevp75Commented:
Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'

hmm....now I'm wondering if Baby Web Server supports a global.asa file?

I will look into it
lukegriffiths110Author Commented:
If it doesn't, do you no an alternative e.g. brinkster or 1asphot.
lukegriffiths110Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.