PDA

View Full Version : Rusty, please help...


Dimension
06-13-2003, 08:09 PM
Geez, can't step away from doing this for 2 months with out getting lost. Here is the problem. I have a login script, but it is sending the ODBC Error, Too few parameters. Expected 1. On line 9

Code:
<!--#INCLUDE FILE="../includes/scripts/adovbs.inc" -->
<!--#INCLUDE FILE="../includes/scripts/dbconnection.asp" -->
<%
strSQL = "SELECT FNAME, PASSWORD FROM Members " _
& "WHERE FNAME=" & Replace(Request.Form("username"), "", "''") & " " _
& "AND PASSWORD='" & Replace(Request.Form("password"), "'", "''") & "';"
Set rs = Server.CreateObject("ADODB.Recordset")
'excute
rs.Open strsql, FF_Conn
If not rs.EOF or rs.BOF Then
'set params for successful login
Session("Login") = 1
Session("User_ID") = rs("ID")
Session("ACCESS") = rs("ID")
Response.Redirect "../index.asp"
Else
'set params for unseccessful login
Session("Login") = 0
Response.Redirect "../user/failure.asp"
End If

'close the recordset
rs.close
set rs = nothing

'close the connection
FF_Conn.close
set conn = nothing
%>

Any help will be welcomed..
BTW, I have checked the username and password values, both of them are there. I can write from the database, permissions are set etc. Just can't hunt down this problem.

Thanks!

Angelika
06-13-2003, 08:40 PM
Try this:
<!--#INCLUDE FILE="../includes/scripts/dbconnection.asp" -->
<%
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT FNAME,PASSWORD FROM Members "
strSQL=strSQL + "FNAME='"&Request.Form("username")&"' "
strSQL=strSQL + "AND PASSWORD='"&Request.Form("password")&"'"
rs.Open strSQL,FF_Conn
If not rs.EOF or rs.BOF Then
'set params for successful login
Session("Login") = 1
Session("User_ID") = rs("ID")
Session("ACCESS") = rs("ID")
Response.Redirect "../index.asp"
Else
'set params for unseccessful login
Session("Login") = 0
Response.Redirect "../user/failure.asp"
End If

'close the recordset
rs.close
set rs = nothing

'close the connection
FF_Conn.close
set conn = nothing
%>

Dimension
06-13-2003, 09:25 PM
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

/stephen/asp/login.asp, line 7


Thats what i got...

Angelika
06-13-2003, 09:42 PM
Sorry , my mistake.
Try this:
<!--#INCLUDE FILE="../includes/scripts/dbconnection.asp" -->
<%
username=Request.Form("username")
password=Request.Form("password")

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT FNAME,PASSWORD FROM Members "
strSQL=strSQL + "Where FNAME='"&username&"' "
strSQL=strSQL + "AND PASSWORD='"&password&"'"
rs.Open strSQL,FF_Conn
If not rs.EOF or rs.BOF Then
'set params for successful login
Session("Login") = 1
Session("User_ID") = rs("ID")
Session("ACCESS") = rs("ID")
Response.Redirect "../index.asp"
Else
'set params for unseccessful login
Session("Login") = 0
Response.Redirect "../user/failure.asp"
End If

'close the recordset
rs.close
set rs = nothing

'close the connection
FF_Conn.close
set conn = nothing
%>

Dimension
06-14-2003, 09:14 AM
You are the man!

So, Thanks for the answer, but, "The only stupid mistake is the one you dont learn from!"
All you done was put the form values in a variable?

Thanks!
Randall

Angelika
06-14-2003, 10:04 AM
You so nice!
Yes, I put the form values in a variable and .... change SQL statement - sometimes it's help. Or you didn’t see it?

Dimension
06-14-2003, 10:11 AM
Seen that you changed the sql statement, never seen it done that way before though. With the +'s. Interesting.

Didnt see what? lol If there was a problem in the code, no I didnt. I looked it up and down!

Thanks!

Dimension
06-14-2003, 12:27 PM
Another problem...:rolleyes:

Okay, I have set where it is supposed to redirect the user to the failure page if it doesnt find the user, or the password is incorrect...

Code:
<!--#INCLUDE FILE="../includes/scripts/dbconnection.asp" -->
<%
username=Request.Form("username")
password=Request.Form("password")

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT * FROM Roster "
strSQL=strSQL + "Where FNAME='"&username&"' "
strSQL=strSQL + "AND PASSWORD='"&password&"'"
rs.Open strSQL,FF_Conn
If not rs.EOF or rs.BOF Then
'set params for successful login
Session("Login") = 1
Session("Name") = rs("FNAME")
Session("User_ID") = rs("ID")
Session("Access") = rs("ACCESS")
Response.Redirect "../index.asp"
Else
'set params for unseccessful login
Session("Login") = 0
Response.Redirect "../user/failure.asp"
End If

'close the recordset
rs.close
set rs = nothing

'close the connection
FF_Conn.close
set conn = nothing
%>

Error:
ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/stephen/asp/login.asp, line 15


Geez, sorry for me being so stupid!

Dimension
06-14-2003, 12:30 PM
Opps...Nevermind, I got it...Sorry! :)