 |
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

April 18th, 2004, 03:59 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Syntax error for chapter 15 AddUser.asp
Help!!!!!!
I have been battling this error for two days now and i am uanble to resolve it.
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in FROM clause.
/AddUser.asp, line 5
Why is this computer smarter than me?
|

April 18th, 2004, 04:09 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
[code]
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\DataStores\userlogin.mdb"
If Session("blnValidUser") = True and Session("PersonID") = "" Then
Dim rsPersonIDCheck
Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL = "SELECT PersonID FROM Person " & _
"WHERE EmailAddress = '" & Session("EmailAddress") & "';"
rsPersonIDCheck.Open strSQL, objConn
If rsPersonIDCheck.EOF Then
Session("blnValidUser") = False
Else
Session("PersonID") = rsPersonIDCheck("PersonID")
End If
rsPersonIDCheck.Close
Set rsPersonIDCheck = Nothing
End If
|

April 19th, 2004, 01:54 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
It looks like your SQL statement is syntactically correct, so it must be that either PersonID or Person does not exist. Does your database have a table called Person? And does that table have a column called PersonID? Or is it called just ID? In that case, you should use SELECT Person.ID FROM Person.....
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Killers' Lullaby by Faithless (Track 11 from the album: Sunday 8PM)
|

April 19th, 2004, 10:07 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I checked what you suggested and all the information was correct. except that this code that I uploaded did not have the
current DBname which i hace since then fixed. but I still get the same error. I wonder if there is something wrong with the connection to the actual db. The connection string seems to be ok. Any other suggestions?
Maybe explainin what this is trying to do will help shed a light on the matter. This code fragment is set up to do two things. one is open a connection to the database, the other is to retrieve the persons ID if the person has registered before. This is also the script that is called when you are adding a new user to the database. Maybe I am confused, but if this is the case would you get en error if you have never registered and you are tryin gto retrieve your person ID?
Im fairly new to this coding stuff so alot of things dont compute until i smack into them. maybe i am not seeing something.
Thanks for your help.
George
And So the next day begins.
Alas.
|

April 19th, 2004, 10:55 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I stumbled accross a link as I was looking around the archives for the answer to this problem. The link helped to explain why my the error i was getting was happening. It turns out as i mentioned above i "updated the name of the database to user. I was not aware the User was a reserved word. So I changed the name and no longer get that error. I have instead stumbled across a new error. This one might be simpler to solve but my lack of knowledge on ASP is starting to impede my progress.
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'rs'
/AddUser.asp, line 10
here is the code: the include file is attached at the end of this code. thanks
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.Open "User", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable
If Session("PersonID") <> "" Then 'currently logged-on user
rs.Users.Filter = "PersonID = '" & Session("PersonID") & "'"
Else ' New session
rs.Users.Filter = "EmailAddress = '" & Request.Form("email") & "'" & _
"AND Password = '" & Request.Form("Password") & "'"
If rs.Users.EOF Then ' User not found
rsUsers.AddNew ' add a new record
' Else
' Email address and password matched with DB records -
' The user will be allowed to update his personal details
End If
End If
'write personal details to record
rsUsers("EmailAddress") = Request.Form("email")
rsUsers("Password") = Request.Form("Password")
rsUsers("FirstName") = Request.Form("firstname")
rsUsers("LastName") = Request.Form("lastname")
rsUsers("StreetAddress1") = Request.Form("address1")
rsUsers("StreetAddress2") = Request.Form("address2")
rsUsers("City") = Request.Form("city")
rsUsers("State") = Request.Form("state")
rsUsers("PostalCode") = Request.Form("postalcode")
rsUsers("Active") = True
rsUsers("LastLogin") = Now
rsUsers.Update ' updates the database
Dim StrName, strValue ' create session variables
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
Session("blnValidUser") = True ' shows current user is valid
Response.Redirect "MenuForRegisteredUsers.asp"
include file:
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\inetpub\wwwroot\userlogin.mdb"
If Session("blnValidUser") = True and Session("PersonID") = "" Then
Dim rsPersonIDCheck
Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL = "SELECT PersonID FROM Person WHERE EMailAddress = '" & Session("EMailAddress") & "' ;"
rsPersonIDCheck.Open strSQL, objConn
If rsPersonIDCheck.EOF Then
Session("blnValidUser") = False
Else
Session("PersonID") = rsPersonIDCheck("PersonID")
End If
rsPersonIDCheck.Close
Set rsPersonIDCheck = Nothing
End If
And So the next day begins.
Alas.
|

April 20th, 2004, 01:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hmmm, not sure I understand the previous explanation, What did you previously call User and did you rename it now? I didn't see a thing called user in your previous posts....
Anyway, yeah, this one is easier:
Code:
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.Open "User", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable
If Session("PersonID") <> "" Then 'currently logged-on user
rs.Users.Filter = "PersonID = '" & Session("PersonID") & "'"
Else
' New session
...
As you can see, you create a recordset called rsUsers, but later you use rs.Users.....
Instead of opening the entire table and then filtering the requested user, it's a lot quicker to send a SELECT statement with a WHERE clause to the database, to only retrieve te requested user. This save quite a lot of overhead.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: 01 - New born by Muse (Track 1 from the album: Origin of symmetry)
|

April 20th, 2004, 01:52 AM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar thanks so much for your help.
I managed to figure out that error. Thanks to the <%opotiond Explicit%> function. I realized the erroe right away.
for the sake of clarification in the earliest post i made i posted the table name as person whereas in the script i had changed it to user.
And So the next day begins.
Alas.
|

April 20th, 2004, 02:00 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Aha, which also fixed the problem in the post, but not in the original page ;) That's why it's often useful to post code exactly as you have it in your pages.....
Option Explicit is always very useful to have turned on... It's one of your biggest aid in debugging....
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Falling Away With You by Muse (Track 6 from the album: Absolution)
|
|
 |