robojob
08-12-2005, 07:59 PM
i have a login script and i am trying to query the database based on the username that is stored in a session, the code i have for this page is below. When i login and it directs me to that page i see the following error:
Script error detected at line 21.
Source line: rs.Open strSQL, adoCon, 3, 3
Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
I am guessing that i have done summit wrong with the coding of the opening of the database and the query.... can anyone tell me whats wrong with it please....
<%
username = Session("loginfailure")
if ("" = username) Then
response.Write("Sorry, you are not logged in.")
response.End
End if
%>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("project_database.mdb")
'adoCon.Open "DSN=login"
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM register Where username = '"& Session("username") &"';"
rs.Open strSQL, adoCon, 3, 3
IF NOT rs.EOF THEN
FName=rs("user_name")
rs.Close
Set rs = Nothing
adoCon.Close
Set adoCon = Nothing
End If
%>
<HTML>
<head>
<title>Final Login Page after logged in</title>
<style>
</head>
<body TOPMARGIN=0 LEFTMARGIN=5 MARGINWIDTH=5 MARGINHEIGHT=0>
<br>
<br>
<br>
<table valign=top border=0 bordercolor="#ffffff" width="100%" cellspacing=0 cellpadding=0>
<tr>
<td align="left" valign=top>
<TABLE WIDTH="80%" BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="center" style="border-style: solid; border-color: #0000CC">
<TR>
<TD BGCOLOR="#0000FF" CLASS="hea" HEIGHT="20">
<DIV ALIGN="center"><font face="Verdana,Arial" color="#ffffff"><b>Final
Page</b></font></DIV>
</TD>
</TR>
<TR>
<TD BGCOLOR="#33ccff">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="8" BGCOLOR="#EFEFEF">
<TR>
<TD CLASS="small">
<p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><B>Congratulation!
</B></font>
<p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><b>
<br>You
have successfully logged in to our site</b></font><p align="left"><font size="3" face="Verdana,Arial" color="#0000ff">
<p align="left">
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</table>
Welcome <%Fname%>.
<a href="logout.asp">Log out</a>
</BODY>
</html>
Script error detected at line 21.
Source line: rs.Open strSQL, adoCon, 3, 3
Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
I am guessing that i have done summit wrong with the coding of the opening of the database and the query.... can anyone tell me whats wrong with it please....
<%
username = Session("loginfailure")
if ("" = username) Then
response.Write("Sorry, you are not logged in.")
response.End
End if
%>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("project_database.mdb")
'adoCon.Open "DSN=login"
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM register Where username = '"& Session("username") &"';"
rs.Open strSQL, adoCon, 3, 3
IF NOT rs.EOF THEN
FName=rs("user_name")
rs.Close
Set rs = Nothing
adoCon.Close
Set adoCon = Nothing
End If
%>
<HTML>
<head>
<title>Final Login Page after logged in</title>
<style>
</head>
<body TOPMARGIN=0 LEFTMARGIN=5 MARGINWIDTH=5 MARGINHEIGHT=0>
<br>
<br>
<br>
<table valign=top border=0 bordercolor="#ffffff" width="100%" cellspacing=0 cellpadding=0>
<tr>
<td align="left" valign=top>
<TABLE WIDTH="80%" BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="center" style="border-style: solid; border-color: #0000CC">
<TR>
<TD BGCOLOR="#0000FF" CLASS="hea" HEIGHT="20">
<DIV ALIGN="center"><font face="Verdana,Arial" color="#ffffff"><b>Final
Page</b></font></DIV>
</TD>
</TR>
<TR>
<TD BGCOLOR="#33ccff">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="8" BGCOLOR="#EFEFEF">
<TR>
<TD CLASS="small">
<p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><B>Congratulation!
</B></font>
<p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><b>
<br>You
have successfully logged in to our site</b></font><p align="left"><font size="3" face="Verdana,Arial" color="#0000ff">
<p align="left">
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</table>
Welcome <%Fname%>.
<a href="logout.asp">Log out</a>
</BODY>
</html>