Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error?

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
dear experts,


I'm having an error..

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

Pls Correct?
____________________________________________________________

<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;en-us&quot;>
</head>

<body>
<div align=&quot;center&quot;>
<center>
<table border=&quot;1&quot; width=&quot;97%&quot; bgcolor=&quot;#74C288&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;14%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>TYPE</font></td>
<td width=&quot;14%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Position</font></td>
<td width=&quot;15%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Agency</font></td>
<td width=&quot;11%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Item No</font></td>
<td width=&quot;18%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Salary Grade</font></td>
<td width=&quot;17%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Requirements</font></td>
<td width=&quot;15%&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>Date Released</font></td>
</tr>
</table>

</center>
</div>
<!-- #include file=&quot;adovbs.inc&quot; -->

<%
Dim txtsearch
Dim txtcategory
Dim ConnString
Dim Page_Size
Dim Current_Page
Dim Page_Count,count
Dim MyConn, RS, SQL

txtsearch = Request.Form(&quot;strSearch&quot;)
txtcategory = Request.Form(&quot;opt_search&quot;)

Page_Size = 5 'this is where you set the # of records displayed per page

If Request(&quot;Page&quot;) = &quot;&quot; Then
Current_Page = 1
Else
Current_Page = CInt(Request(&quot;Page&quot;))
End If



Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)


Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
ConnString = &quot;DBQ=&quot; & Server.Mappath(&quot;..\database\database.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;

Set RS=Server.CreateObject(&quot;ADODB.RecordSet&quot;)
MyConn.Open ConnString


RS.CursorLocation = adUseClient

RS.PageSize = Page_Size


SQL = &quot;Select * From tblPost_Job where &quot; &txtcategory& &quot; LIKE '%&quot; & txtsearch & &quot;%'&quot;

RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText

Page_Count = RS.PageCount


If 1 > Current_Page Then Current_Page = 1
If Current_Page > Page_Count Then Current_Page = Page_Count

RS.AbsolutePage = Current_Page

Do While RS.AbsolutePage = Current_Page And Not RS.EOF

%>

<div align=&quot;center&quot;>
<center>

<table width=&quot;97%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;14&quot; bgcolor=&quot;#E3D5B9&quot;>
<tr>
<td width=&quot;14%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;jobtype&quot;)%></font></td>
<td width=&quot;14%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;jobposition&quot;)%></font></td>
<td width=&quot;15%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;agency&quot;)%></font></td>
<td width=&quot;11%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;itemno&quot;)%></font></td>
<td width=&quot;18%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;salarygrade&quot;)%></font></td>
<td width=&quot;17%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;requirements&quot;)%></font></td>
<td width=&quot;15%&quot; align=&quot;center&quot; height=&quot;12&quot;><font face=&quot;Arial&quot; size=&quot;1&quot;><%=RS(&quot;datereleased&quot;)%></font></td>
</tr>
</table>

</center>
</div>

<%

RS.MoveNext

Loop

RS.Close

Set RS = Nothing
MyConn.Close

Set MyConn = Nothing

Response.Write &quot;<center>&quot;
'below is the page navigation using links.
Response.Write &quot;<td colspan=&quot;&quot;4&quot;&quot; align=&quot;&quot;center&quot;&quot;>&quot;
If Current_Page = 1 Then
Response.Write &quot;<font color=&quot;&quot;silver&quot;&quot; & size=&quot;&quot;2&quot;&quot;>&quot; & &quot;First </font><font size=&quot;&quot;2&quot;&quot;>&nbsp;|</font> &quot;
End If
If Current_Page >= 2 Then
Response.Write &quot;<a href=&quot;&quot;search_job.asp?Page=1&quot;
Response.Write &quot;&quot;&quot;><font size=&quot;&quot;2&quot;&quot;><< First</font></a><font size=&quot;&quot;2&quot;&quot;> |</font> &quot; & vbCrLf
End If
If Current_Page >= Page_Count Then
Response.Write &quot;<font color=&quot;&quot;silver&quot;&quot; Size=&quot;&quot;2&quot;&quot;>Next >></font><font size=&quot;&quot;2&quot;&quot;> |&nbsp;</font>&quot;
End If
If Current_Page < Page_Count Then
Response.Write &quot;<a href=&quot;&quot;search_job.asp?Page=&quot;
Response.Write Current_Page + 1
Response.Write &quot;&quot;&quot;><font size=&quot;&quot;2&quot;&quot;>Next ></font></a>&quot; & &quot;&nbsp;<font size=&quot;&quot;2&quot;&quot;>|</font>&quot; & vbCrLf
End IF
If Current_Page <> 1 Then
Response.Write &quot;<a href=&quot;&quot;search_job.asp?Page=&quot;
Response.Write Current_Page - 1
Response.Write &quot;&quot;&quot;><font size=&quot;&quot;2&quot;&quot;>< Previous </font></a><font size=&quot;&quot;2&quot;&quot;>&nbsp; |</font> &quot; & vbCrLf
Response.Write &quot; &quot; & vbCrLf
End If
If Current_Page = 1 Then
Response.Write &quot;<font color=&quot;&quot;silver&quot;&quot; & size=&quot;&quot;2&quot;&quot;>&quot; & &quot;< Previous </font><font size=&quot;&quot;&quot;&quot;>|</font> &quot;
End If
If Current_Page <> Page_Count Then
Response.Write &quot;<a href=&quot;&quot;search_job.asp?Page=&quot;
Response.Write Page_Count
Response.Write &quot;&quot;&quot;><font size=&quot;&quot;2&quot;&quot;>Last >></font></a>&quot; & vbCrLf
End If
If Current_Page >= Page_Count Then
Response.Write &quot;<font size=&quot;&quot;2&quot;&quot; color=&quot;&quot;silver&quot;&quot;>Last</font>&quot; & &quot;</font>&quot;
End If

%>
<br>
<Center>Page <%=Current_Page%> of <%=Page_Count%></center>


<br>

</body>
</html>




Joel,
 
Hi Joel,
Try to insert some space before Like in SQL query.I think that will solve your problem
 
This could be because &quot;txtcategory&quot; may be returning a null value.. so in which case your query would look like this:

Select * From tblPost_Job where LIKE '%SomeText%'

Which would cause your error.. Try outputting the value's of your search for debugging.. (both txtcategory and txtsearch).

Cheers,

G.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top