man_im_bored
05-04-03, 22:07
Yeah, I'm starting to learn ASP, and what I'm trying to create is a login. I've set up the db and created a way for people to add a username and password to the db, but I can't get someone to "login" which is a pain. In the db, I've got two colums: 1)username and 2)passcol - which is the password column.
It connects successfully and everything, just doesn't run the query.
Here's the error:
'Technical Information (for support personnel)
'Error Type:
'Microsoft JET Database Engine (0x80040E14)
'Characters found after end of SQL statement.
'/programming/asp/login/login_engine.asp, line 34
- - - - - - - - - - - - - - - - - - - - - CODE - - - - - - - - - - - - - - - - - - - - - -
<%
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The SQL Query we build on the fly
Dim strUser ' Username
Dim strPass ' Password
strUser= Request.Form("username")
strPass= Request.Form("passbox")
If strUser <> "" Then
If strPass <> "" Then
strDBPath = Server.MapPath("db.mdb")
Set cnnSearch = Server.CreateObject("ADODB.Connection")
cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\programming\asp\login\db.mdb;"
' Build our query based on the input.
strSQL = "SELECT username, passcol " _
& "FROM usertable " _
& "WHERE username = strUser;" _
& "AND passcol = strPass "
' Execute our query using the connection object. It automatically
' creates and returns a recordset which we store in our variable.
Set rstSearch = cnnSearch.Execute(strSQL)
Do While Not rstSearch.EOB
Do While Not rstSearch.EOF
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
Response.Redirect("failed.asp")
Loop
Loop
Response.Redirect("success.asp")
End If
else
Response.Redirect("failed.asp")
End if
%>
:D
It connects successfully and everything, just doesn't run the query.
Here's the error:
'Technical Information (for support personnel)
'Error Type:
'Microsoft JET Database Engine (0x80040E14)
'Characters found after end of SQL statement.
'/programming/asp/login/login_engine.asp, line 34
- - - - - - - - - - - - - - - - - - - - - CODE - - - - - - - - - - - - - - - - - - - - - -
<%
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The SQL Query we build on the fly
Dim strUser ' Username
Dim strPass ' Password
strUser= Request.Form("username")
strPass= Request.Form("passbox")
If strUser <> "" Then
If strPass <> "" Then
strDBPath = Server.MapPath("db.mdb")
Set cnnSearch = Server.CreateObject("ADODB.Connection")
cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\programming\asp\login\db.mdb;"
' Build our query based on the input.
strSQL = "SELECT username, passcol " _
& "FROM usertable " _
& "WHERE username = strUser;" _
& "AND passcol = strPass "
' Execute our query using the connection object. It automatically
' creates and returns a recordset which we store in our variable.
Set rstSearch = cnnSearch.Execute(strSQL)
Do While Not rstSearch.EOB
Do While Not rstSearch.EOF
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
Response.Redirect("failed.asp")
Loop
Loop
Response.Redirect("success.asp")
End If
else
Response.Redirect("failed.asp")
End if
%>
:D