lukegriffiths110
asked on
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.as p, 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>
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.as
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>
ASKER
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.OL EDB.4.0;Da ta 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> </td>
<td><input type=submit value="Log me in!" name=submit1 class=defaultsmall></td>
</tr>
</table>
</form>
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.OL
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> </td>
<td><input type=submit value="Log me in!" name=submit1 class=defaultsmall></td>
</tr>
</table>
</form>
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?
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?
p.s. you still shoul make that chagne in global.asa (this way your connection isn't constantly open)
ASKER
I am using a baby server i have given the error on the top of the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
The error is now:-
Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'
Script error detected at line 32.
Source line: conn.Open Application("connString")
Description: Type mismatch: 'Application'
ASKER
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.
http://www.codeproject.com/asp/user_logtime.asp
Could you look at it and sse if it is useable.
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
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
ASKER
If it doesn't, do you no an alternative e.g. brinkster or 1asphot.
ASKER
It looks like baby server does support global.asa:-
http://www.softpedia.com/get/Internet/Servers/WEB-Servers/Baby-ASP-Web-Server.shtml
http://www.softpedia.com/get/Internet/Servers/WEB-Servers/Baby-ASP-Web-Server.shtml
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