PDA

View Full Version : Getting Odd SQL Error message


Opacus
January 27th, 2005, 04:20 PM
Ok, so I have no idea why a certain web page is giving up this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'LIKE'.

/iframe-searchwarranty.asp, line 157



When I look at the ASP code it looks like this:


<% 'on error resume next
sql= "select warrantynumber, custname, custCity, custState, date_warranty_request_doc, Date_installation_doc, date_rgn_doc from warranty_doc where"
'use j variable to select if put an "AND"
'use k variable to select if the statement will show or not
j=0
k=0
For each item in request.form

if (len(Trim(Request.Form(item)))>0 and item<>"Submit22") then
fieldname=item
fieldnameValue=replace(Request.Form(item),"'","''")
if j=1 then
sql = sql &" AND "
end if
sql=sql & fieldname &" LIKE '"&trim(fieldnamevalue)&"%' "
j=1
k=1
end if
Next
sql = sql & " order by warrantynumber DESC, custName ASC"
%>


When I parse the SQL in QueryAnalyzer it is all happy and fun. PLEASE tell me what I am doing wrong... I have been trying to work this out for hours now and there is very little in the way of help on that particular error...

I am ever so grateful for you even reading my post, have a great day.

Steven.Bentley
January 30th, 2005, 07:25 PM
I'd echo (or the ASP equivalent) out the sql variable, see what the full query is and see whether that looks right