[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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