INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Asp database connection for login fails

Asp database connection for login fails

(OP)
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




RE: Asp database connection for login fails


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

RE: Asp database connection for login fails

You have the fields reversed. Should be something like:

CODE

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

RE: Asp database connection for login fails

(OP)
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 sad
Is it possible to indicate where (the) quotes (or no quotes) must be placed ?
Thanks - Leifoet

RE: Asp database connection for login fails

Did you see my post?

RE: Asp database connection for login fails

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

RE: Asp database connection for login fails

??

Quote (me on 7 Apr 16 14:26)

You have the fields reversed. Should be something like:

CODE

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

RE: Asp database connection for login fails

(OP)
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

RE: Asp database connection for login fails

>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 

RE: Asp database connection for login fails

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

RE: Asp database connection for login fails

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close