[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression

Hi,

I know this probably is partly a database question... but I didn't know if it was mostly the ASP or the database problems...

I am getting this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Id3 ='.

- line 32

everything works fine, except when I click on a message to view it
please go here: http://www.redwaybc.ca/forum/index.asp click on a discussion board (general)
then try to click on a message... "Page cannot be found"


Here is the error-causing code:

<!-- #include file="Config.inc" -->
<html>

<head>
<title>RedWAY BC Forums</title>

<body bgcolor="<%= BackgroundColor %>"  link="<%= LinkColor %>" vlink="<%= LinkColorVisited %>" alink="<%= LinkColorActive %>">
</head>


<%= note %>

      <table align=center width=80% cellspacing=0 cellpadding=0 border=0>
      <tr>      
      
      <td class="content" align=left valign=top>
      

      <font style="font-family=<%= DiscussionStandardFontFace %>;color=<%= DiscussionStandardFontColor %>;font-size=<%= DiscussionStandardFontSize %>">



<%

Id3 = Request.Querystring("Id3")

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(vPath & "messages.mdb"))

sSQL = "SELECT Id1, Id2, Id3, Date, Title, Content, Name, Email, Locked, Password, OriginalMessage FROM messages WHERE Id3 = " & Id3

Set Message = oConn.Execute(sSQL)

Id1 = Message("Id1").Value
Id2 = Message("Id2").Value
Id3 = Message("Id3").Value
Locked = Message("Locked").Value
Password = Message("Password").Value
%>

<!-- Begin LockCheck -->
<%
If Locked = "Yes" and Session("forumpassword") <> Password Then
%>

<font size=4><b>Locked discussion, please login</b></font><br>

<form name="Login" action="DoLogin.asp" method=post>
<input type="hidden"name="id3" value="<%= id3 %>">
This is a locked discussion. Please enter the password in order to gain access to the discussion.<br>
If you already tried to login on this one, then you probably entered the wrong password. Please try again.<br>
<br>
Password: <input type="password" name="password" size=20>
<input type="Submit" value="Login"><br>
<% If Session("Mod") = "Yes" Then %>
<%
If Password = "" Then
DisplayPassword = "<i>No Password</i>"
Else
DisplayPassword = Password
End If
%>
<br>
<b>You are a Moderator.</b> The password is: <font color="Red"><%= DisplayPassword %></font>
<% End If %>

</form>

<% Else %>
      


<table width=100% cellspacing=0 cellpadding=0 border=0>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionTitleFontFace %>;color=<%= DiscussionTitleFontColor %>;font-size=<%= DiscussionTitleFontSize %>"><b>
<%= Message("Title").Value %>
</b></font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=right>
<font style="font-family=<%= DiscussionInfoFontFace %>;color=<%= DiscussionInfoFontColor %>;font-size=<%= DiscussionInfoFontSize %>">
Submitted by <a href="mailto:<%= Message("Email").Value %>"><%= Message("Name").Value %></a> on <%= Message("Date").Value %>
<% If Session("Mod") = "Yes" Then %>
      <% If Message("OriginalMessage") <> "Yes" Then %>
             | <a href="Delete.asp?Id3=<%= Id3 %>" target="_new"><font color="Red">Del Message</font></a>
       <% End If %> | <a href="Delete.asp?Id2=<%= Id2 %>" target="_new"><font color="Red"><b>Del Thread</b></font></a>
<% End If %>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionMessageFontFace %>;color=<%= DiscussionMessageFontColor %>;font-size=<%= DiscussionMessageFontSize %>">
<%
ContentRAW = Message("Content").Value
Content = convert(ContentRAW)

Response.Write LinkURLs(Content)
%>
<br>
<br>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<form name="Respond" action="Form_Respond.asp" method=post>
      <input type="hidden" name="Id1" value="<%= Id1 %>">
      <input type="hidden" name="Id2" value="<%= Id2 %>">
      <input type="hidden" name="Id3" value="<%= Id3 %>">
      <input type="hidden" name="Locked" value="<%= Locked %>">
      <input type="hidden" name="Password" value="<%= Password %>">
      <input type="Submit" value="Respond to this message"><br>
<< <font face="Arial" size=2><a href="index.asp?id1=<%= Id1 %>">Back to the Forum</a></font><br>
>> <font face="Arial" size=2><a href="MessageAll.asp?id2=<%= id2 %>&id3=<%= id3 %>">View all the messages from this thread</a></font><br>
</form>

</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

</tr>
<td colspan=3 height=10></td>
</tr>


<%
sSQL2 = "SELECT Id3, Date, Title, Name FROM messages WHERE Id2 = " & Id2 & " ORDER BY Id3"
Set Reactions = oConn.Execute(sSQL2)
%>


<% Do While NOT Reactions.EOF %>

<tr bgcolor="<%= TableDiscussionColorDark %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td width=55% height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
      <b><%= Reactions("Title").Value %></b>
<% Else %>
      <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td width=25% align=left>
<%= Reactions("Name").Value %>
</td>

<td width=20% align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
%>

<% If Reactions.EOF Then %>
            <tr>
            <td></td>
            <td></td>
            <td></td>
            </tr>
<% Else %>


<tr bgcolor="<%= TableDiscussionColorLight %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
      <b><%= Reactions("Title").Value %></b>
<% Else %>
      <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td align=left>
<%= Reactions("Name").Value %>
</td>

<td align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
End If
Loop
%>


</table>

<!-- Closing LockCheck -->
<% End If %>
      </table>
</body>
</html>
olivekoalaAsked:
Who is Participating?
 
fritz_the_blankCommented:
So like a complete moron, I fixed the sql select but did not include it in the final code that I suggested!!!  (Thanks Anthony!!!)

Here is an update to avoid confusion:



<!-- #include file="Config.inc" -->
<html>

<head>
<title>RedWAY BC Forums</title>

<body bgcolor="<%= BackgroundColor %>"  link="<%= LinkColor %>" vlink="<%= LinkColorVisited %>" alink="<%= LinkColorActive %>">
</head>


<%= note %>

     <table align=center width=80% cellspacing=0 cellpadding=0 border=0>
     <tr>    
     
     <td class="content" align=left valign=top>
     

     <font style="font-family=<%= DiscussionStandardFontFace %>;color=<%= DiscussionStandardFontColor %>;font-size=<%= DiscussionStandardFontSize %>">



<%

Id3 = Request.Querystring("Id3")

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(vPath & "messages.mdb"))

if Id3 <> "" and not isEmpty(Id3) and Id3 >0 then
   sSQL = "SELECT Id1, Id2, Id3, [Date], Title, Content, [Name], Email, Locked, [Password], OriginalMessage FROM messages WHERE Id3 = " & Id3

     Set Message = oConn.Execute(sSQL)
else
     response.write("No value for ID3!")
     response.end
end if

Id1 = Message("Id1").Value
Id2 = Message("Id2").Value
Id3 = Message("Id3").Value
Locked = Message("Locked").Value
Password = Message("Password").Value
%>

<!-- Begin LockCheck -->
<%
If Locked = "Yes" and Session("forumpassword") <> Password Then
%>

<font size=4><b>Locked discussion, please login</b></font><br>

<form name="Login" action="DoLogin.asp" method=post>
<input type="hidden"name="id3" value="<%= id3 %>">
This is a locked discussion. Please enter the password in order to gain access to the discussion.<br>
If you already tried to login on this one, then you probably entered the wrong password. Please try again.<br>
<br>
Password: <input type="password" name="password" size=20>
<input type="Submit" value="Login"><br>
<% If Session("Mod") = "Yes" Then %>
<%
If Password = "" Then
DisplayPassword = "<i>No Password</i>"
Else
DisplayPassword = Password
End If
%>
<br>
<b>You are a Moderator.</b> The password is: <font color="Red"><%= DisplayPassword %></font>
<% End If %>

</form>

<% Else %>
     


<table width=100% cellspacing=0 cellpadding=0 border=0>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionTitleFontFace %>;color=<%= DiscussionTitleFontColor %>;font-size=<%= DiscussionTitleFontSize %>"><b>
<%= Message("Title").Value %>
</b></font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=right>
<font style="font-family=<%= DiscussionInfoFontFace %>;color=<%= DiscussionInfoFontColor %>;font-size=<%= DiscussionInfoFontSize %>">
Submitted by <a href="mailto:<%= Message("Email").Value %>"><%= Message("Name").Value %></a> on <%= Message("Date").Value %>
<% If Session("Mod") = "Yes" Then %>
     <% If Message("OriginalMessage") <> "Yes" Then %>
           | <a href="Delete.asp?Id3=<%= Id3 %>" target="_new"><font color="Red">Del Message</font></a>
      <% End If %> | <a href="Delete.asp?Id2=<%= Id2 %>" target="_new"><font color="Red"><b>Del Thread</b></font></a>
<% End If %>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionMessageFontFace %>;color=<%= DiscussionMessageFontColor %>;font-size=<%= DiscussionMessageFontSize %>">
<%
ContentRAW = Message("Content").Value
Content = convert(ContentRAW)

Response.Write LinkURLs(Content)
%>
<br>
<br>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<form name="Respond" action="Form_Respond.asp" method=post>
     <input type="hidden" name="Id1" value="<%= Id1 %>">
     <input type="hidden" name="Id2" value="<%= Id2 %>">
     <input type="hidden" name="Id3" value="<%= Id3 %>">
     <input type="hidden" name="Locked" value="<%= Locked %>">
     <input type="hidden" name="Password" value="<%= Password %>">
     <input type="Submit" value="Respond to this message"><br>
<< <font face="Arial" size=2><a href="index.asp?id1=<%= Id1 %>">Back to the Forum</a></font><br>
>> <font face="Arial" size=2><a href="MessageAll.asp?id2=<%= id2 %>&id3=<%= id3 %>">View all the messages from this thread</a></font><br>
</form>

</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

</tr>
<td colspan=3 height=10></td>
</tr>


<%
sSQL2 = "SELECT Id3, Date, Title, Name FROM messages WHERE Id2 = " & Id2 & " ORDER BY Id3"
Set Reactions = oConn.Execute(sSQL2)
%>


<% Do While NOT Reactions.EOF %>

<tr bgcolor="<%= TableDiscussionColorDark %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td width=55% height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
     <b><%= Reactions("Title").Value %></b>
<% Else %>
     <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td width=25% align=left>
<%= Reactions("Name").Value %>
</td>

<td width=20% align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
%>

<% If Reactions.EOF Then %>
          <tr>
          <td></td>
          <td></td>
          <td></td>
          </tr>
<% Else %>


<tr bgcolor="<%= TableDiscussionColorLight %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
     <b><%= Reactions("Title").Value %></b>
<% Else %>
     <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td align=left>
<%= Reactions("Name").Value %>
</td>

<td align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
End If
Loop
%>


</table>

<!-- Closing LockCheck -->
<% End If %>
     </table>
</body>
</html>
0
 
fritz_the_blankCommented:
I am guessing that line 32 is around here?

sSQL = "SELECT Id1, Id2, Id3, Date, Title, Content, Name, Email, Locked, Password, OriginalMessage FROM messages WHERE Id3 = " & Id3

Set Message = oConn.Execute(sSQL)


0
 
fritz_the_blankCommented:
First, you are using some reserved words, so let's see if we can fix that:

sSQL = "SELECT Id1, Id2, Id3, [Date], Title, Content, [Name], Email, Locked, [Password], OriginalMessage FROM messages WHERE Id3 = " & Id3

Set Message = oConn.Execute(sSQL)


FtB
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
fritz_the_blankCommented:
Next--the error message makes me suspect that you are getting no value for ID3. Are you sure that a value is being passed?

FtB
0
 
fritz_the_blankCommented:
So, try this:

<!-- #include file="Config.inc" -->
<html>

<head>
<title>RedWAY BC Forums</title>

<body bgcolor="<%= BackgroundColor %>"  link="<%= LinkColor %>" vlink="<%= LinkColorVisited %>" alink="<%= LinkColorActive %>">
</head>


<%= note %>

     <table align=center width=80% cellspacing=0 cellpadding=0 border=0>
     <tr>    
     
     <td class="content" align=left valign=top>
     

     <font style="font-family=<%= DiscussionStandardFontFace %>;color=<%= DiscussionStandardFontColor %>;font-size=<%= DiscussionStandardFontSize %>">



<%

Id3 = Request.Querystring("Id3")

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(vPath & "messages.mdb"))

if Id3 <> "" and not isEmpty(Id3) and Id3 >0 then
      sSQL = "SELECT Id1, Id2, Id3, Date, Title, Content, Name, Email, Locked, Password, OriginalMessage FROM messages WHERE Id3 = " & Id3

      Set Message = oConn.Execute(sSQL)
else
      response.write("No value for ID3!")
      response.end
end if

Id1 = Message("Id1").Value
Id2 = Message("Id2").Value
Id3 = Message("Id3").Value
Locked = Message("Locked").Value
Password = Message("Password").Value
%>

<!-- Begin LockCheck -->
<%
If Locked = "Yes" and Session("forumpassword") <> Password Then
%>

<font size=4><b>Locked discussion, please login</b></font><br>

<form name="Login" action="DoLogin.asp" method=post>
<input type="hidden"name="id3" value="<%= id3 %>">
This is a locked discussion. Please enter the password in order to gain access to the discussion.<br>
If you already tried to login on this one, then you probably entered the wrong password. Please try again.<br>
<br>
Password: <input type="password" name="password" size=20>
<input type="Submit" value="Login"><br>
<% If Session("Mod") = "Yes" Then %>
<%
If Password = "" Then
DisplayPassword = "<i>No Password</i>"
Else
DisplayPassword = Password
End If
%>
<br>
<b>You are a Moderator.</b> The password is: <font color="Red"><%= DisplayPassword %></font>
<% End If %>

</form>

<% Else %>
     


<table width=100% cellspacing=0 cellpadding=0 border=0>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionTitleFontFace %>;color=<%= DiscussionTitleFontColor %>;font-size=<%= DiscussionTitleFontSize %>"><b>
<%= Message("Title").Value %>
</b></font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=right>
<font style="font-family=<%= DiscussionInfoFontFace %>;color=<%= DiscussionInfoFontColor %>;font-size=<%= DiscussionInfoFontSize %>">
Submitted by <a href="mailto:<%= Message("Email").Value %>"><%= Message("Name").Value %></a> on <%= Message("Date").Value %>
<% If Session("Mod") = "Yes" Then %>
     <% If Message("OriginalMessage") <> "Yes" Then %>
           | <a href="Delete.asp?Id3=<%= Id3 %>" target="_new"><font color="Red">Del Message</font></a>
      <% End If %> | <a href="Delete.asp?Id2=<%= Id2 %>" target="_new"><font color="Red"><b>Del Thread</b></font></a>
<% End If %>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<font style="font-family=<%= DiscussionMessageFontFace %>;color=<%= DiscussionMessageFontColor %>;font-size=<%= DiscussionMessageFontSize %>">
<%
ContentRAW = Message("Content").Value
Content = convert(ContentRAW)

Response.Write LinkURLs(Content)
%>
<br>
<br>
</font>
</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

<tr>
<td colspan=3 align=left>
<form name="Respond" action="Form_Respond.asp" method=post>
     <input type="hidden" name="Id1" value="<%= Id1 %>">
     <input type="hidden" name="Id2" value="<%= Id2 %>">
     <input type="hidden" name="Id3" value="<%= Id3 %>">
     <input type="hidden" name="Locked" value="<%= Locked %>">
     <input type="hidden" name="Password" value="<%= Password %>">
     <input type="Submit" value="Respond to this message"><br>
<< <font face="Arial" size=2><a href="index.asp?id1=<%= Id1 %>">Back to the Forum</a></font><br>
>> <font face="Arial" size=2><a href="MessageAll.asp?id2=<%= id2 %>&id3=<%= id3 %>">View all the messages from this thread</a></font><br>
</form>

</td>
</tr>

</tr>
<td colspan=3 height=5 background="Images/Horiz_Line.gif"></td>
</tr>

</tr>
<td colspan=3 height=10></td>
</tr>


<%
sSQL2 = "SELECT Id3, Date, Title, Name FROM messages WHERE Id2 = " & Id2 & " ORDER BY Id3"
Set Reactions = oConn.Execute(sSQL2)
%>


<% Do While NOT Reactions.EOF %>

<tr bgcolor="<%= TableDiscussionColorDark %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td width=55% height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
     <b><%= Reactions("Title").Value %></b>
<% Else %>
     <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td width=25% align=left>
<%= Reactions("Name").Value %>
</td>

<td width=20% align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
%>

<% If Reactions.EOF Then %>
          <tr>
          <td></td>
          <td></td>
          <td></td>
          </tr>
<% Else %>


<tr bgcolor="<%= TableDiscussionColorLight %>" style="font-family=<%= DiscussionReactionsFontFace %>;color=<%= DiscussionReactionsFontColor %>;font-size=<%= DiscussionReactionsFontSize %>">

<td height=30 align=left>
<% actief = Reactions("Id3").Value eqv Id3 %>

<% If actief=true Then %>
     <b><%= Reactions("Title").Value %></b>
<% Else %>
     <a href="Message.asp?id3=<%= Reactions("Id3").Value %>"><%= Reactions("Title").Value %></a>
<% End If %>
</td>

<td align=left>
<%= Reactions("Name").Value %>
</td>

<td align=left>
<%= Reactions("Date").Value %>
</td>

</tr>

<%
Reactions.MoveNext
End If
Loop
%>


</table>

<!-- Closing LockCheck -->
<% End If %>
     </table>
</body>
</html>
0
 
fritz_the_blankCommented:
If that fixes the error, then you need to go back and recode to ensure that your page always passes the correct parameters and to ensure error handling like I have above to handle those intances where a parameter does not come accross.

FtB
0
 
Anthony PerkinsCommented:
And don't forget to enclose keywords with [] in fritz's code :)

fritz,

For the record according to MSDN "Name" is not a JET keyword, but "Names" is.
0
 
gladxmlCommented:
try to checkout the link might help...

troubleshooting error
http://www.adopenstatic.com/faq/80040e14.asp

reserved words...
http://www.btgi.net/reservedwords.cfm

Happy debugging...

0
 
fritz_the_blankCommented:
A split between me and ACPerkins?

FtB
0
 
Anthony PerkinsCommented:
>>A split between me and ACPerkins?<<
I beg to differ:  I made no substantial contributions to this solution, I merely corroborated your answer.  The points are all yours.
0
 
olivekoalaAuthor Commented:
I apologize, I had been in a car accident and by the time I recovered I had lost the job and recieved an e-mail saying that my experts exchange account had been suspended. so, I apologize and thank all who have participated.
0
 
fritz_the_blankCommented:
Glad to have helped but am sorry to hear about your misfortune.

FtB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.