Groups | Blog | Home
all groups > inetserver asp db > april 2006 >

inetserver asp db : syntax error in FROM clause


Mike Brind
4/24/2006 5:52:56 AM

[quoted text, click to view]

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

[quoted text, click to view]

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 <the actual name of the column where user names are stored> = '"
& Session("strUserName") & "';"

--
Mike Brind
Mike Brind
4/24/2006 11:47:44 AM
So - does your other post to this group still require attention?

--
Mike Brind


[quoted text, click to view]
Varun Jain
4/24/2006 12:48:01 PM
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
%>

<!--#include file="V2E2Connection.asp"-->

<%
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
%>

<HTML>
<HEAD>

<SCRIPT language="JavaScript">
<!--
function VerifyData()
{
if (document.frmUser.strPassword.value !=
document.frmUser.strVerifyPassword.value)
{
alert ("Your passwords do not match - please reenter");
return false;
}
else
return true;
}
-->
</SCRIPT>

<TITLE>Update Personal Details</TITLE>
</HEAD>

<BODY>

<H1>Update user details</H1>

<FORM ACTION="UpdateUser.asp" NAME="frmUpdateUser" METHOD=POST
onSubmit="return VerifyData()">
<P>Password: <INPUT TYPE="Password" NAME="strPassword"
VALUE="<%=Session("strPassword")%>"></P>
<P>Verify Password: <INPUT TYPE="Password" NAME="strVerifyPassword"
VALUE="<%=Session("strPassword")%>"></P>
<P>First Name: <INPUT TYPE="TEXT" NAME="strFirstName"
VALUE="<%=Session("strFirstName")%>"></P>
<P>Family Name: <INPUT TYPE="TEXT" NAME="strFamilyName"
VALUE="<%=Session("strFamilyName")%>"></P>
<P>Gender: <INPUT TYPE="TEXT" NAME="strGender"
VALUE="<%=Session("strGender")%>"></P>
<P>Age: <INPUT TYPE="TEXT" NAME="intAge"
VALUE="<%=Session("intAge")%>"></P>
<P>Course: <INPUT TYPE="TEXT" NAME="strCourse"
VALUE="<%=Session("strCourse")%>"></P>
<BR>
<P><INPUT TYPE = "SUBMIT" VALUE="Confirm changes"></P>
</FORM>

</BODY>
</HTML>

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

<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
'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&strFamilyName=who&strGender=male&intAge=10&strCourse=who

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


f.. More information:
Microsoft Support

Drew
4/24/2006 12:51:33 PM
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

[quoted text, click to view]

Bob Barrows [MVP]
4/24/2006 1:19:32 PM
[quoted text, click to view]
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.

Varun Jain
4/24/2006 5:38:28 PM
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


[quoted text, click to view]

Varun Jain
4/24/2006 6:22:08 PM
Thanks Drew,
I got it sorted anyways. I added the LockType, Cursor and other parameters
and changed CmdTable to CmdText and it worked.
[quoted text, click to view]

AddThis Social Bookmark Button