473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

syntax error

I get this error and can't figure out the correct syntax.
Doesn't seem to make a difference changing the quotes around.
Thanks!
---------------------
Syntax error (missing operator) in query expression 'GenKTitles.Title= White
Christmas'.
---------------------
<%
Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""
Set rsResults = DataConn.Open(SQL)
%>
Jul 19 '05 #1
14 1500
> SQL = SQL & " WHERE GenKTitles.Title= "" + SearchTerm + ""
Jul 19 '05 #2
> SQL = SQL & " WHERE GenKTitles.Title= "" + SearchTerm + ""
Jul 19 '05 #3
or

SQL = SQL & " WHERE GenKTitles.Title= " & Chr(34) & Trim(SearchTerm) &
Chr(34)

Also check www.aspfaq.com to handle the problem with ' and " in string. In
my country name or often like D'haese whta cause a problem when you surround
the searchstring by "'" + searchstring + "'"
Jul 19 '05 #4
or

SQL = SQL & " WHERE GenKTitles.Title= " & Chr(34) & Trim(SearchTerm) &
Chr(34)

Also check www.aspfaq.com to handle the problem with ' and " in string. In
my country name or often like D'haese whta cause a problem when you surround
the searchstring by "'" + searchstring + "'"
Jul 19 '05 #5
> SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""

Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #6
> SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""

Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #7
Sorry, that last + should be &

Shank, + is addition, while it doubles as string concatenation in VBScript,
you should try to always use & to avoid issues.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)

Jul 19 '05 #8
Sorry, that last + should be &

Shank, + is addition, while it doubles as string concatenation in VBScript,
you should try to always use & to avoid issues.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)

Jul 19 '05 #9
That worked! Thanks! But now I'm getting this error...
The query should return valid records. What object is missing?
------------------------
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'open(...)'

------------------------
<%
Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line
%>

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0****************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)

Jul 19 '05 #10
That worked! Thanks! But now I'm getting this error...
The query should return valid records. What object is missing?
------------------------
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'open(...)'

------------------------
<%
Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line
%>

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0****************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)

Jul 19 '05 #11
You created an instance of a Recordset not a Connection...
Set DataConn = Server.CreateObject("ADODB.Recordset")

Bob Lehmann

"shank" <sh***@tampabay.rr.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
That worked! Thanks! But now I'm getting this error...
The query should return valid records. What object is missing?
------------------------
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'open(...)'

------------------------
<%
Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line
%>

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0****************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)


Jul 19 '05 #12
You created an instance of a Recordset not a Connection...
Set DataConn = Server.CreateObject("ADODB.Recordset")

Bob Lehmann

"shank" <sh***@tampabay.rr.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
That worked! Thanks! But now I'm getting this error...
The query should return valid records. What object is missing?
------------------------
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'open(...)'

------------------------
<%
Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line
%>

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:u0****************@TK2MSFTNGP09.phx.gbl...
SQL = SQL & "WHERE GenKTitles.Title= " + SearchTerm + ""


Try:

SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"

--
http://www.aspfaq.com/
(Reverse address to reply.)


Jul 19 '05 #13
> Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line


Where are you getting this syntax from? It's all wrong. Please tell us
where it came from so we can correct the source and ask them to stop
providing faulty code.

First off, you created an ADODB.Recordset as an object with conn in the
name. Surely that's a mistake. Second, a connection object returns a
recordset object to rsResults by calling connectionObject.EXECUTE(sql), not
connectionObject.OPEN(sql). How about this:

SearchTerm = "White Christmas"
set conn = CreateObject("ADODB.Connection")
conn.open MM_GenKAccess_STRING
sql = "SELECT ... "
set rsResults = conn.execute(sql)

And PLEASE, PLEASE, PLEASE STOP USING SELECT * !!!!!!!!!!!!!!!!! And it
wouldn't hurt to stop letting Macromedia products create big, unreadable and
error-prone variable names, either.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #14
> Dim DataConn, SQL
SearchTerm = "White Christmas"
Set DataConn = Server.CreateObject("ADODB.Recordset")
DataConn.ActiveConnection = MM_GenKAccess_STRING
SQL = "SELECT GenKStock.*, GenKTitles.* "
SQL = SQL & "FROM GenKStock INNER JOIN GenKTitles ON GenKStock.OrderNo =
GenKTitles.ItemNumber "
SQL = SQL & "WHERE GenKTitles.Title= '" & SearchTerm + "'"
Set rsResults = DataConn.Open(SQL) <-- ERROR on this line


Where are you getting this syntax from? It's all wrong. Please tell us
where it came from so we can correct the source and ask them to stop
providing faulty code.

First off, you created an ADODB.Recordset as an object with conn in the
name. Surely that's a mistake. Second, a connection object returns a
recordset object to rsResults by calling connectionObject.EXECUTE(sql), not
connectionObject.OPEN(sql). How about this:

SearchTerm = "White Christmas"
set conn = CreateObject("ADODB.Connection")
conn.open MM_GenKAccess_STRING
sql = "SELECT ... "
set rsResults = conn.execute(sql)

And PLEASE, PLEASE, PLEASE STOP USING SELECT * !!!!!!!!!!!!!!!!! And it
wouldn't hurt to stop letting Macromedia products create big, unreadable and
error-prone variable names, either.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #15

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

Similar topics

14
by: sam | last post by:
When I run this SQL query: SELECT u.*, o.* FROM users u, orders o WHERE TO_DAYS(o.order_date) BETWEEN TO_DAYS('2003-09-20')-10 AND TO_DAYS('2003-09-20')+10
1
by: Steve | last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way. ...
29
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"...
1
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
by: david | last post by:
Anyone could give me a hand about this syntax error? Thank you. David Source Code: Dim conn As New SqlConnection(strConn) Dim daAngio As New SqlDataAdapter(strSelectStatement, conn) 'Create a...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
4
by: nickyeng | last post by:
i calling this piece of java code in jsp : List<Customer> list = Customer.listby_page(currentRs); ... ... then it gives me the following error:
0
by: Timothy Grant | last post by:
On Thu, Aug 28, 2008 at 1:40 AM, Alexis Boutillier <alexis.boutillier@arteris.comwrote: So if you were writing C code and the file failed to compile you would still expect to have a working...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.