Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp database connection for login fails

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
0
0
BE
I try to establish a login with a (test) Access database users.mdb => 1 table : userlist with 5 fields (and 4 test records)
field 1 => ldn-ID (autonumber = long integer)
field 2 => Fname (text)
field 3 => Lname (text)
(field 4 => username)
(field 5 => password)


<%
'Check if user is logged in
if Session("uid") = "" then
'If not, go to login page
Response.Redirect("login.asp")
else
'If, build page
Response.Write("<title>ASP Page</title>")
Response.write("<center>Welcome " & Session("uid") & "<br><a href=logout.asp>Logout</a></center>")

Response.Write (Session("uid")) => TEST => I receive : 3 => login.asp works and verify.asp 'takes' 3 (third record) from the database = OK


set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
set rs = server.CreateObject ("ADODB.Recordset")

rs.Open "SELECT Fname,Lname FROM userlist WHERE session("uid") = '"& ldn-id &"'", conn, 1

If I try to become the corresponding names from the same record (n° 3) => the browser gives the following error :

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test_apple/default.asp, line 33
rs.Open "SELECT Fname,Lname FROM userlist WHERE session("uid") = '"& leden-id &"'", conn, 1
------------------------------------------------------------------^

What is wrong with the code ?
Thank for tips - Leifoet




 

The quotes are out of order because of this .... session("uid")




Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
You have the fields reversed. Should be something like:
Code:
rs.Open "SELECT Fname,Lname FROM userlist WHERE [ldn-id] = '"& session("uid") & "'", conn, 1

 
I tried with this quotes :

Microsoft VBScript compilation error '800a0401'
Expected end of statement
/test_apple/default.asp, line 33
rs.Open "SELECT voornaam,familienaam FROM userlist WHERE session("uid") = "& ldn-id &"", conn, 1
------------------------------------------------------------------^

and others
=> same error

Are there quotes too much or too little ? I try to understand the error, but :-(
Is it possible to indicate where (the) quotes (or no quotes) must be placed ?
Thanks - Leifoet

 
Dear Guitarzan,
Not seen - where can I read it ?
Thx Leifoet
 
??

me on 7 Apr 16 14:26 said:
You have the fields reversed. Should be something like:
Code:
rs.Open "SELECT Fname,Lname FROM userlist WHERE [ldn-id] = '"& session("uid") & "'", conn, 1
 
I still got errors :

Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.
/test_apple/default.asp, line 33
line 33 => rs.Open "SELECT Fname,Lname FROM userlist WHERE [ldn-id] = '"& session("uid") & "'", conn, 1

I tried also his
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/test_apple/default.asp, line 33
line 33 => rs.Open "SELECT Fname,Lname FROM userlist WHERE ldn-id = '"& session("uid") & "'", conn, 1


What could be the cause?
Thanks for tips - Leifoet
 
>I still got errors
Yes but a different error, which means the first error was fixed

Now, what data type is ldn-id? If it's numeric, then don't surround the value in single quotes.

Code:
rs.Open "SELECT Fname,Lname FROM userlist WHERE [ldn-id] = "& session("uid"), conn, 1
 
print out the string that is your query instead of sending to the SQL server so you can actually see what is being sent.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
The query is working - now I can continue.
Thanks you for help.

I have still one small (detail) question : what is de meaning of the "1" at the end of the query ? (and not "2" or "3" or ... )
(or where can I find an explanation).

Thanks - leifoet

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top