• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

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>
0
lukegriffiths110
Asked:
lukegriffiths110
  • 7
  • 5
1 Solution
 
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
0
 
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>
0
 
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?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
kevp75Commented:
p.s.  you still shoul make that chagne in global.asa  (this way your connection isn't constantly open)
0
 
lukegriffiths110Author Commented:
I am using a baby server i have given the error on the top of the code.
0
 
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
0
 
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
0
 
lukegriffiths110Author Commented:
The error is now:-

Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'
0
 
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.
0
 
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
0
 
lukegriffiths110Author Commented:
If it doesn't, do you no an alternative e.g. brinkster or 1asphot.
0
 
lukegriffiths110Author Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now