473,695 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax error (missing operator) in query expression

Hello! I've written 2 pages: one i HTML format, and second - in ASP. When
I'm posting data from HTML page, I receive this error generated by ASP page:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression '' AND ([ID
Platnika]='OFFICE DEPOT')''.

"Office Depot" is the value from form.

When all values are set to "*" the script generates correct results, but if
its value contains any string it generates the error message shown above.
And this is the code of ASP page:

Dim pT1
Dim pT2
Dim pD1
Dim pD2
Dim pD3
Dim pD4
Dim pK1
Dim pD5
Dim pTP1
Dim pTP2

pT1 = request("T1")
pT2 = request("T2")
pD1 = request("D1")
pD2 = request("D2")
pD3 = request("D3")
pD4 = request("D4")
pK1 = request("K1")
pD5 = request("D5")
pTP1 = request("TP1")
pTP2 = request("TP2")

Dim mySQL 'SQL command to execute
Dim objPagingConn 'The ADODB connection object
Dim objPagingRS 'The ADODB recordset object

Set objPagingConn = Server.CreateOb ject("ADODB.Con nection")
objPagingConn.O pen "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" &
Server.MapPath( "../db2.mdb") & ";"
Set objPagingRS = Server.CreateOb ject("ADODB.Rec ordset")

mySQL = ""

If pT1 <> "" And pT2 <> "" Then
mySQL = mySQL & " AND (Data BETWEEN '" & Request ("T1") & "' AND '" &
Request ("T2") & "')"
End If

If pD1 <> "*" Then
mySQL = mySQL & " AND ([Numer faktury]='" & Request ("D1") & "')"
End If

If pD2 <> "*" Then
mySQL = mySQL & " AND ([ID Platnika]='" & Request ("D2") & "')"
End If

If pD3 <> "*" Then
mySQL = mySQL & " AND ([Kategoria]='" & Request ("D3") & "')"
End If

If pD4 <> "*" Then
mySQL = mySQL & " AND ([ID faktury]='" & Request ("D4") & "')"
End If

'If pK1 <> "*" Then
'mySQL = mySQL & " AND ([Kwota]='" & Request ("K1") & "')"
'End If

If pD5 <> "*" Then
mySQL = mySQL & " AND ([Status]='" & Request ("D5") & "')"
End If

If pTP1 <> "" And pTP2 <> "" Then
mySQL = mySQL & " AND ([Termin platnosci] BETWEEN '" & Request ("TP1") & "'
AND '" & Request ("TP2") & "')"
End If

If mySQL <> "" Then
mySQL = "WHERE '" & mySQL & "'"
End If

mySQL = "SELECT Data, [Numer faktury], [ID Platnika], Kategoria, [ID
faktury], [Kwota], Status, [Termin platnosci] FROM [Faktury tabela
zbierajaca faktury przychodzace]" & mySQL
'mySQL = mySQL & ";"

objPagingRS.Ope n mySQL, objPagingConn, 1,1 ', adOpenStatic, adLockReadOnly,
adCmdText %>

<% Do While Not objPagingRS.EOF %>
<% response.write objPagingRS("Nu mer faktury") %>"><% response.write
objPagingRS("Nu mer faktury") %><BR>
<% objPagingRS.Mov eNext

objPagingRS.Clo se
Set objPagingRS = Nothing
objPagingConn.C lose
Set objPagingConn = Nothing


Can anybody tell me what is wrong with this code?
What kind of parentes should I use to prevent this error? I'm using '" &
variable & "' ..... Maybe there is another statement?
Please, help!!!
Jul 19 '05 #1
1 11121
See below for the best technique to debug this:
Maciej Paras wrote:
Hello! I've written 2 pages: one i HTML format, and second - in ASP.
When I'm posting data from HTML page, I receive this error generated
by ASP page:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression '' AND ([ID
Platnika]='OFFICE DEPOT')''.
mySQL = "SELECT Data, [Numer faktury], [ID Platnika], Kategoria, [ID
faktury], [Kwota], Status, [Termin platnosci] FROM [Faktury tabela
zbierajaca faktury przychodzace]" & mySQL
'mySQL = mySQL & ";"

Right here:

Response.Write mySQL

You have no hope of debugging this without knowing exactly what sql
statement you are sending to the database. So, take a look at the result of
the response.write in the browser window. The problem should stand out, but,
if it doesn't, copy and paste the statement from the browser window the the
SQL View of a Query Builder window in Access. Try to run it. At the very
least, you will probably get a better error message.

If you still can't figure it out, show us the sql statement.

Bob Barrows
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.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" & REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE("GenKTitles.
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out on me for some reason. The Summary field is pulled from a Rich Text Editor that allows HTML formatting and appears to be the culprit, but I just can't seem to figure out why. Any guidance is greatly appreciated. I'm connecting to an Access...
by: Lumpierbritches | last post by:
Syntax Error (missing operator) in query expression =BLANK'S MOLLIE-PRINCE BRUISER-3/14/2004-03 AnimalID is correct. I'm trying to open with a command button or double click the frmAnimal from a subform that uses the same table, is that my problem? If I remove the criteria from the expression, it opens the form, but to show every record.
by: khan | last post by:
getting, error, 3075 Syntax Error (Missing Operator) in query expression '8WHERE .=1' Dim TotalQty As Integer TotalQty = DLookup("", "", "=" & Forms!!)
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double quotes? Do I need to use code to scrub each string and remove or escape the double quotes before using it in a query? The error I get is this: Error Number 3075: Syntax error (missing operator) in query expression '"credit card billed by...
by: T. Wintershoven | last post by:
Hi Can someone please tell me whats wrong with the last line of the query below. The first three lines work fine but when i add the fourth line i get an error message (see text at ERROR MESSAGE) sql_HTTermijnRecords = "select * from Orders where FaktuurGeprint = 'J'" & _ "AND dathergestuurd Is Not Null " & _ "AND PerBankKas Is Null " & _
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is expression should return the 4 leftmost characters of the FilmNo
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.