|
 |
access_asp thread: Expected end of statement Error
Message #1 by "Liberty Powers" <libertypowers@a...> on Mon, 13 Jan 2003 05:19:54
|
|
I'm using an Access database, and I'm having problems
running queries with ASP...
here's my code:
<%
Dim objRec
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.ActiveConnection = strConnect
objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
AssignmentDescription FROM tbAssignment WHERE AssignmentSection
="Section1""
objRec.CursorType = 0
objRec.CursorLocation = 2
objRec.LockType = 1
objRec.Open( )
Response.Write RecToTable (objRec)
objRec.Close
Set objRec = Nothing
%>
I get this error message:
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/Clar106/section1/default.asp, line 76, column 126
objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
AssignmentDescription FROM tbAssignment WHERE AssignmentSection
="Section1""
---------------------------------------------------------------------------
--------------------------------------------------^
I've also tried this to fix it, but it returns yet another error:
<%
Dim objRec
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.ActiveConnection = strConnect
objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
AssignmentDescription FROM tbAssignment WHERE AssignmentSection =" &
Section1 & ""
objRec.CursorType = 0
objRec.CursorLocation = 2
objRec.LockType = 1
objRec.Open( )
Response.Write RecToTable (objRec)
objRec.Close
Set objRec = Nothing
%>
The error I get is:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator)
in query expression 'AssignmentSection ='.
/Clar106/section1/default.asp, line 81
Can anyone help me?
Message #2 by "Francisco Gonzalez" <fjgm@t...> on Mon, 13 Jan 2003 15:45:43 -0400
|
|
Hi,
You need to enclosed Section1 between single apostrophes. Like this
'Section1' or double ""Section1"". All comparison with string constant in a
Select statement needs to be.
Try:
objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
AssignmentDescription FROM tbAssignment WHERE AssignmentSection
'Section1' "
That should fix your problem.
Francisco
----- Original Message -----
From: "Liberty Powers" <libertypowers@a...>
To: "Access ASP" <access_asp@p...>
Sent: Monday, January 13, 2003 5:19 AM
Subject: [access_asp] Expected end of statement Error
> I'm using an Access database, and I'm having problems
>
>
> running queries with ASP...
>
>
>
>
> here's my code:
>
>
> <%
>
>
>
>
>
> Dim objRec
>
>
> Set objRec = Server.CreateObject("ADODB.Recordset")
>
>
> objRec.ActiveConnection = strConnect
>
>
>
>
>
> objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
> AssignmentDescription FROM tbAssignment WHERE AssignmentSection
> ="Section1""
>
>
>
>
>
> objRec.CursorType = 0
>
>
> objRec.CursorLocation = 2
>
>
> objRec.LockType = 1
>
>
> objRec.Open( )
>
>
>
>
>
>
>
>
> Response.Write RecToTable (objRec)
>
>
>
>
>
>
>
>
> objRec.Close
>
>
> Set objRec = Nothing
>
>
>
>
>
> %>
>
>
>
>
> I get this error message:
>
>
> Error Type:
>
>
> Microsoft VBScript compilation (0x800A0401)
>
>
> Expected end of statement
>
>
> /Clar106/section1/default.asp, line 76, column 126
>
>
> objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
> AssignmentDescription FROM tbAssignment WHERE AssignmentSection
> ="Section1""
>
>
> --------------------------------------------------------------------------
-
> --------------------------------------------------^
>
>
>
>
>
>
>
>
> I've also tried this to fix it, but it returns yet another error:
>
>
>
>
> <%
>
>
>
>
>
> Dim objRec
>
>
> Set objRec = Server.CreateObject("ADODB.Recordset")
>
>
> objRec.ActiveConnection = strConnect
>
>
>
>
>
> objRec.Source = "SELECT AssignmentTitle, AssignmentSection,
> AssignmentDescription FROM tbAssignment WHERE AssignmentSection =" &
> Section1 & ""
>
>
>
>
>
> objRec.CursorType = 0
>
>
> objRec.CursorLocation = 2
>
>
> objRec.LockType = 1
>
>
> objRec.Open( )
>
>
>
>
>
>
>
>
> Response.Write RecToTable (objRec)
>
>
>
>
>
>
>
>
> objRec.Close
>
>
> Set objRec = Nothing
>
>
>
>
>
> %>
>
>
>
>
>
>
>
>
> The error I get is:
>
>
> Error Type:
>
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
>
>
> [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator)
> in query expression 'AssignmentSection ='.
>
>
> /Clar106/section1/default.asp, line 81
>
>
>
>
>
>
>
>
> Can anyone help me?
|
|
 |