We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Global asa

lukegriffiths110
on
Medium Priority
463 Views
Last Modified: 2012-08-14
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>
Comment
Watch Question

Commented:
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

Author

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>

Commented:
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?

Commented:
p.s.  you still shoul make that chagne in global.asa  (this way your connection isn't constantly open)

Author

Commented:
I am using a baby server i have given the error on the top of the code.
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

Author

Commented:
The error is now:-

Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'

Author

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.

Commented:
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

Author

Commented:
If it doesn't, do you no an alternative e.g. brinkster or 1asphot.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.