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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC Error Code = 37000 Syntax error (missing operator) in query

Status
Not open for further replies.

philcha

Programmer
May 10, 2000
109
0
0
GB
I have some code which dynamically assembles the following query:<br>Select ItAcCd, ItTxNum, ItTxDate, ItAmt, ItXrefAc, BkTxn.TxNarr From BkItem, BkTxn Where BkTxn.TxNum = BkItem.ItTxNum And BkItem.ItAcCd = 'NCA'<br>I know it generates exactly this because in desperation I inserted &lt;cfoutput&gt;#QueryString#&lt;/cfoutput&gt; to see what was going on.<br>'NCA' is the dynamic bit, derived from user input.<br><br>This gives the following error:<br>ODBC Error Code = 37000 (Syntax error or access violation)<br>[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'BkTxn.TxNum = BkItem.ItTxNum And BkItem.ItAcCd = ''NCA'''.<br>SQL = &quot;Select ItAcCd, ItTxNum, ItTxDate, ItAmt, ItXrefAc, BkTxn.TxNarr From BkItem, BkTxn Where BkTxn.TxNum = BkItem.ItTxNum And BkItem.ItAcCd = ''NCA'' Order by ItTxDate, BkTxn.TxNum&quot;<br><br>I can't see what's wrong.&nbsp;&nbsp;I copied the generated query into VB's Visdata Add-in and it ran OK!<br><br>Can anyone help?<br>
 
The double-quotes around NCA are probably causing this.&nbsp;&nbsp;They should be single-quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top