SteveH
11-14-2008, 06:17 PM
Hello
I am using the following 'user log in' script, but it generates the following error:
[Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'.
/LOGin/logIN.asp, line 30
Does this mean that the database (MS Access 2003) is corrupt?
Many thanks.
Steve
<!-- #INCLUDE FILE="data.asp" -->
<%
Response.Buffer = true
%>
<%
'-- Check if Submit button pushed, if not ignore the entire script
If Request.Form("btnAdd") = "Submit" Then
'-- Make sure all boxes have data entered into them
If Request.Form("name") <> "" OR Request.Form("password") <> "" OR Request.Form("password2") <> "" OR Request.Form("email") <> "" OR Request.Form("userID") <> "" Then
'-- Make sure the passwords match
If Request.Form("password") = Request.Form("password2") Then
'-- Declare your variables
Dim SQL, strError,strEmail, strUserID
'-- Get data from the form fields
strUserName = Request.Form("name")
strPassword = Request.Form("password")
strEmail = Request.Form("email")
strUserID = Request.Form("userID")
'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\myForm.mdb;"
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
'-- default SQL
SQL = "SELECT * FROM tblSecurity"
If Request.Form("name") <> "" Then
SQL = "SELECT tblSecurity.* FROM tblSecurity WHERE tblSecurity.userID='" & strUserID & "' AND tblSecurity.password ='" & strPassword & "' OR tblSecurity.email ='" & strEmail & "'"
End If
cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")
'-- Cursor Type, Lock Type
'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
RecordSet.Open cmdDC, , 0, 2
'-- check to see if the user and password or e-mail address have registered before
If Not RecordSet.EOF Then
If RecordSet.fields("email")=strEmail Then
strError = "<FONT FACE='ARIAL' SIZE='2'><B>Sorry this email has already been registred, please try again</B></FONT>"
Else
'Redo page and say 'this User name and Password are already taken
strError = "<FONT FACE='ARIAL' SIZE='2'><B>Sorry this user name and password are already taken, please try again</B></FONT>"
End If
Else
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject("ADODB.Connection")
Dconn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\myForm.mdb;"
sSQL = "INSERT INTO tblSecurity(name, email, userID, password, userLevel) VALUES ('" & strUserName & "','" & strEmail & "','" & strUserID & "','" & strPassword & "',1)"
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing
'Forward the user to page to notify of authentication
Response.Redirect "youokman.asp"
End If
Else
strError = "Your passwords don't match"
End If
'-- Close all connections
RecordSet.Close
Set RecordSet = Nothing
DataConnection.Close
Set DataConnection = Nothing
Else
'Tell them what they entered wrong
strError = "Please fill in all the boxes"
End If
End If
%>
<!-- HTML FORM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<BODY bgcolor="#FFFFFF" MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" TEXT="#000000">
<%
'-- Error message if there is any
Response.write (strError & "<BR>")
%>
<form method="POST" action="">
<div align="left">
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td width="50%"><font face="Arial" size="2">Full
Name:</font></td>
<td width="50%"><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Email:</font></td>
<td width="50%"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a UserID:</font></td>
<td width="50%"><input type="text" name="userID" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a Password:</font></td>
<td width="50%"><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Confirm
Password:</font></td>
<td width="50%"><input type="password" name="password2" size="20"></td>
</tr>
</table>
</div>
<p><input type="submit" value="Submit" name="btnAdd"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
I am using the following 'user log in' script, but it generates the following error:
[Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'.
/LOGin/logIN.asp, line 30
Does this mean that the database (MS Access 2003) is corrupt?
Many thanks.
Steve
<!-- #INCLUDE FILE="data.asp" -->
<%
Response.Buffer = true
%>
<%
'-- Check if Submit button pushed, if not ignore the entire script
If Request.Form("btnAdd") = "Submit" Then
'-- Make sure all boxes have data entered into them
If Request.Form("name") <> "" OR Request.Form("password") <> "" OR Request.Form("password2") <> "" OR Request.Form("email") <> "" OR Request.Form("userID") <> "" Then
'-- Make sure the passwords match
If Request.Form("password") = Request.Form("password2") Then
'-- Declare your variables
Dim SQL, strError,strEmail, strUserID
'-- Get data from the form fields
strUserName = Request.Form("name")
strPassword = Request.Form("password")
strEmail = Request.Form("email")
strUserID = Request.Form("userID")
'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\myForm.mdb;"
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
'-- default SQL
SQL = "SELECT * FROM tblSecurity"
If Request.Form("name") <> "" Then
SQL = "SELECT tblSecurity.* FROM tblSecurity WHERE tblSecurity.userID='" & strUserID & "' AND tblSecurity.password ='" & strPassword & "' OR tblSecurity.email ='" & strEmail & "'"
End If
cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")
'-- Cursor Type, Lock Type
'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
RecordSet.Open cmdDC, , 0, 2
'-- check to see if the user and password or e-mail address have registered before
If Not RecordSet.EOF Then
If RecordSet.fields("email")=strEmail Then
strError = "<FONT FACE='ARIAL' SIZE='2'><B>Sorry this email has already been registred, please try again</B></FONT>"
Else
'Redo page and say 'this User name and Password are already taken
strError = "<FONT FACE='ARIAL' SIZE='2'><B>Sorry this user name and password are already taken, please try again</B></FONT>"
End If
Else
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject("ADODB.Connection")
Dconn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\myForm.mdb;"
sSQL = "INSERT INTO tblSecurity(name, email, userID, password, userLevel) VALUES ('" & strUserName & "','" & strEmail & "','" & strUserID & "','" & strPassword & "',1)"
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing
'Forward the user to page to notify of authentication
Response.Redirect "youokman.asp"
End If
Else
strError = "Your passwords don't match"
End If
'-- Close all connections
RecordSet.Close
Set RecordSet = Nothing
DataConnection.Close
Set DataConnection = Nothing
Else
'Tell them what they entered wrong
strError = "Please fill in all the boxes"
End If
End If
%>
<!-- HTML FORM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<BODY bgcolor="#FFFFFF" MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" TEXT="#000000">
<%
'-- Error message if there is any
Response.write (strError & "<BR>")
%>
<form method="POST" action="">
<div align="left">
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td width="50%"><font face="Arial" size="2">Full
Name:</font></td>
<td width="50%"><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Email:</font></td>
<td width="50%"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a UserID:</font></td>
<td width="50%"><input type="text" name="userID" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a Password:</font></td>
<td width="50%"><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Confirm
Password:</font></td>
<td width="50%"><input type="password" name="password2" size="20"></td>
</tr>
</table>
</div>
<p><input type="submit" value="Submit" name="btnAdd"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>