syntax error in FROM clause

syntax error in FROM clause

am 24.04.2006 13:48:01 von Varun Jain

I am assuming many people have had this problem before, but here is my code
and then the error. Thank you for any help.

---
Code
---
If Session("strUserName") = "" Then
Response.Redirect "index.asp"
End If
%>



<%
Dim strUserName, strName, strValue
strUserName = Session("strUserName")

Dim rsUsers
set rsUsers = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblPerson WHERE strUserName = '" & strUserName &
"';"

rsUsers.Open strSQL, objConn

Response.Write(strUserName)


For Each strField in rsUsers.Fields
strName = strField.Name ' populate
session variables
strValue = strField.Value
Session(strName) = strValue
Next
%>






Update Personal Details




Update user details



onSubmit="return VerifyData()">

Password: VALUE="<%=Session("strPassword")%>">


Verify Password: VALUE="<%=Session("strPassword")%>">


First Name: VALUE="<%=Session("strFirstName")%>">


Family Name: VALUE="<%=Session("strFamilyName")%>">


Gender: VALUE="<%=Session("strGender")%>">


Age: VALUE="<%=Session("intAge")%>">


Course: VALUE="<%=Session("strCourse")%>">










---
(AS YOU CAN SEE I HAVE INCLUDED V2E2Connection.asp IN THIS FILE. HERE IS THE
CODE FOR THAT
---


<%
'The following code is to be used as a SSI. It has all the data access
connection information.
'It declares a value to hold the database connection and then opens it.
'It also retrieves the current users PersonID from the database, so that it
can be used throughout the session

'Initialising the connection object
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objCOnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= c:\datastores\v2e2.mdb"

'Checking if user is valid and if the PersonID parameter is set.
'If valid user and no personId, then creates a recordset object to get the
personID from the database


If Session("blnVaildUser") = T Then

Dim rsUserNameCheck
Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
Dim strSQL
strSQL = "SELECT * FROM tblPERSON " & _
"WHERE strUserName = '" & Session("strUserName") & "';"
rsUserNameCheck.Open strSQL, objConn


If rsUserNameCheck.EOF Then 'If username is not present in the table
then, invalidate the user and log him out"
Session("blnValidUser") = False
End If
rsUserNameCheck.Close
Set rsUserNameCheck = Nothing
End If
%>

---
Error
---
a.. Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in FROM clause.
/BegASP/public/UpdateUser.asp, line 17


b.. Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

c.. Page:
POST 111 bytes to /BegASP/public/UpdateUser.asp

d.. POST Data:
strPassword=who&strVerifyPassword=who&strFirstName=who&strFa milyName=who&strGender=male&intAge=10&strCourse=who

e.. Time:
Monday, April 24, 2006, 12:42:04 PM


f.. More information:
Microsoft Support

Re: syntax error in FROM clause

am 24.04.2006 14:52:56 von Mike Brind

Varun Jain wrote:
> I am assuming many people have had this problem before, but here is my code
> and then the error. Thank you for any help.

They have. And many discover their error by response.writing their
strSQL to the browser as an aid in debugging.


>
> Dim rsUserNameCheck
> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
> Dim strSQL
> strSQL = "SELECT * FROM tblPERSON " & _
> "WHERE strUserName = '" & Session("strUserName") & "';"

If you add

response.write strSQL : response.end

at this point, and then took the resulting SQL statement to your Access
database and ran it in the SQL view of the Query Pane, you would get a
dialogue box asking for an input against a field called strUserName.
And you would think, hang on a minute - that's not the name of my
field! And you would have discovered the source of the error.

Your strSQL should read:

"SELECT * FROM tblPERSON " & _
"WHERE = '"
& Session("strUserName") & "';"

--
Mike Brind

Re: syntax error in FROM clause

am 24.04.2006 18:38:28 von Varun Jain

Thanks Mike for your reply.

However I did the Response.Write as you said. I took the same command and
ran it in a query in the database (thru access), and it showed me exactly
what I wanted. I have checked the name atleast 10 times now of the username,
the actual database file, everything. Please do tell me if you have any
other suggestions.

Thank you
varun


"Mike Brind" wrote in message
news:1145883175.991294.120030@i39g2000cwa.googlegroups.com.. .
>
> Varun Jain wrote:
>> I am assuming many people have had this problem before, but here is my
>> code
>> and then the error. Thank you for any help.
>
> They have. And many discover their error by response.writing their
> strSQL to the browser as an aid in debugging.
>
>
>>
>> Dim rsUserNameCheck
>> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
>> Dim strSQL
>> strSQL = "SELECT * FROM tblPERSON " & _
>> "WHERE strUserName = '" & Session("strUserName") & "';"
>
> If you add
>
> response.write strSQL : response.end
>
> at this point, and then took the resulting SQL statement to your Access
> database and ran it in the SQL view of the Query Pane, you would get a
> dialogue box asking for an input against a field called strUserName.
> And you would think, hang on a minute - that's not the name of my
> field! And you would have discovered the source of the error.
>
> Your strSQL should read:
>
> "SELECT * FROM tblPERSON " & _
> "WHERE = '"
> & Session("strUserName") & "';"
>
> --
> Mike Brind
>

Re: syntax error in FROM clause

am 24.04.2006 18:51:33 von Drew

Is the username column in the database named, strUserName? If not, change
the code in Mike's reply to reflect the true column name.

Drew

"Varun Jain" wrote in message
news:OJDnL27ZGHA.4564@TK2MSFTNGP03.phx.gbl...
> Thanks Mike for your reply.
>
> However I did the Response.Write as you said. I took the same command and
> ran it in a query in the database (thru access), and it showed me exactly
> what I wanted. I have checked the name atleast 10 times now of the
> username, the actual database file, everything. Please do tell me if you
> have any other suggestions.
>
> Thank you
> varun
>
>
> "Mike Brind" wrote in message
> news:1145883175.991294.120030@i39g2000cwa.googlegroups.com.. .
>>
>> Varun Jain wrote:
>>> I am assuming many people have had this problem before, but here is my
>>> code
>>> and then the error. Thank you for any help.
>>
>> They have. And many discover their error by response.writing their
>> strSQL to the browser as an aid in debugging.
>>
>>
>>>
>>> Dim rsUserNameCheck
>>> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
>>> Dim strSQL
>>> strSQL = "SELECT * FROM tblPERSON " & _
>>> "WHERE strUserName = '" & Session("strUserName") & "';"
>>
>> If you add
>>
>> response.write strSQL : response.end
>>
>> at this point, and then took the resulting SQL statement to your Access
>> database and ran it in the SQL view of the Query Pane, you would get a
>> dialogue box asking for an input against a field called strUserName.
>> And you would think, hang on a minute - that's not the name of my
>> field! And you would have discovered the source of the error.
>>
>> Your strSQL should read:
>>
>> "SELECT * FROM tblPERSON " & _
>> "WHERE = '"
>> & Session("strUserName") & "';"
>>
>> --
>> Mike Brind
>>
>
>

Re: syntax error in FROM clause

am 24.04.2006 19:19:32 von reb01501

Varun Jain wrote:
> Thanks Mike for your reply.
>
> However I did the Response.Write as you said. I took the same command
> and ran it in a query in the database (thru access), and it showed me
> exactly what I wanted. I have checked the name atleast 10 times now
> of the username, the actual database file, everything. Please do tell
> me if you have any other suggestions.
>
How can we help you if you do not show us the result of Response.Write?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: syntax error in FROM clause

am 24.04.2006 19:22:08 von Varun Jain

Thanks Drew,
I got it sorted anyways. I added the LockType, Cursor and other parameters
and changed CmdTable to CmdText and it worked.
"Drew" wrote in message
news:OQ1%23c97ZGHA.508@TK2MSFTNGP02.phx.gbl...
> Is the username column in the database named, strUserName? If not, change
> the code in Mike's reply to reflect the true column name.
>
> Drew
>
> "Varun Jain" wrote in message
> news:OJDnL27ZGHA.4564@TK2MSFTNGP03.phx.gbl...
>> Thanks Mike for your reply.
>>
>> However I did the Response.Write as you said. I took the same command and
>> ran it in a query in the database (thru access), and it showed me exactly
>> what I wanted. I have checked the name atleast 10 times now of the
>> username, the actual database file, everything. Please do tell me if you
>> have any other suggestions.
>>
>> Thank you
>> varun
>>
>>
>> "Mike Brind" wrote in message
>> news:1145883175.991294.120030@i39g2000cwa.googlegroups.com.. .
>>>
>>> Varun Jain wrote:
>>>> I am assuming many people have had this problem before, but here is my
>>>> code
>>>> and then the error. Thank you for any help.
>>>
>>> They have. And many discover their error by response.writing their
>>> strSQL to the browser as an aid in debugging.
>>>
>>>
>>>>
>>>> Dim rsUserNameCheck
>>>> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
>>>> Dim strSQL
>>>> strSQL = "SELECT * FROM tblPERSON " & _
>>>> "WHERE strUserName = '" & Session("strUserName") & "';"
>>>
>>> If you add
>>>
>>> response.write strSQL : response.end
>>>
>>> at this point, and then took the resulting SQL statement to your Access
>>> database and ran it in the SQL view of the Query Pane, you would get a
>>> dialogue box asking for an input against a field called strUserName.
>>> And you would think, hang on a minute - that's not the name of my
>>> field! And you would have discovered the source of the error.
>>>
>>> Your strSQL should read:
>>>
>>> "SELECT * FROM tblPERSON " & _
>>> "WHERE = '"
>>> & Session("strUserName") & "';"
>>>
>>> --
>>> Mike Brind
>>>
>>
>>
>
>

Re: syntax error in FROM clause

am 24.04.2006 20:47:44 von Mike Brind

So - does your other post to this group still require attention?

--
Mike Brind


Varun Jain wrote:
> Thanks Drew,
> I got it sorted anyways. I added the LockType, Cursor and other parameters
> and changed CmdTable to CmdText and it worked.
> "Drew" wrote in message
> news:OQ1%23c97ZGHA.508@TK2MSFTNGP02.phx.gbl...
> > Is the username column in the database named, strUserName? If not, change
> > the code in Mike's reply to reflect the true column name.
> >
> > Drew
> >
> > "Varun Jain" wrote in message
> > news:OJDnL27ZGHA.4564@TK2MSFTNGP03.phx.gbl...
> >> Thanks Mike for your reply.
> >>
> >> However I did the Response.Write as you said. I took the same command and
> >> ran it in a query in the database (thru access), and it showed me exactly
> >> what I wanted. I have checked the name atleast 10 times now of the
> >> username, the actual database file, everything. Please do tell me if you
> >> have any other suggestions.
> >>
> >> Thank you
> >> varun
> >>
> >>
> >> "Mike Brind" wrote in message
> >> news:1145883175.991294.120030@i39g2000cwa.googlegroups.com.. .
> >>>
> >>> Varun Jain wrote:
> >>>> I am assuming many people have had this problem before, but here is my
> >>>> code
> >>>> and then the error. Thank you for any help.
> >>>
> >>> They have. And many discover their error by response.writing their
> >>> strSQL to the browser as an aid in debugging.
> >>>
> >>>
> >>>>
> >>>> Dim rsUserNameCheck
> >>>> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
> >>>> Dim strSQL
> >>>> strSQL = "SELECT * FROM tblPERSON " & _
> >>>> "WHERE strUserName = '" & Session("strUserName") & "';"
> >>>
> >>> If you add
> >>>
> >>> response.write strSQL : response.end
> >>>
> >>> at this point, and then took the resulting SQL statement to your Access
> >>> database and ran it in the SQL view of the Query Pane, you would get a
> >>> dialogue box asking for an input against a field called strUserName.
> >>> And you would think, hang on a minute - that's not the name of my
> >>> field! And you would have discovered the source of the error.
> >>>
> >>> Your strSQL should read:
> >>>
> >>> "SELECT * FROM tblPERSON " & _
> >>> "WHERE = '"
> >>> & Session("strUserName") & "';"
> >>>
> >>> --
> >>> Mike Brind
> >>>
> >>
> >>
> >
> >