Solved

You have an error in your SQL syntax

Posted on 2007-11-24
4
190 Views
Last Modified: 2010-03-20
I moved my database from Access to MySQL. I then installed ODBC 3.51 driver for MySQL.

I'm getting the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[MySQL][ODBC 3.51 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Student Number] = 'Student Number' AND Not [Student Number] = '') OR ([Student ' at line 1
/aspDump/uploader.asp, line 173

The query its referring to is:

query2 = "SELECT * FROM webctgrades WHERE (([Student Number] = '" & records(3) & "' AND Not [Student Number] = '') OR ([Student ID] = '" & records(2) & "' AND NOT [Student ID] = '')) And Record = '2' And [Course Number] = '" & courseNum & "'"

I've checked the fieldnames and table name and all appear to be identical.

Any help would be seriously appreciated.
0
Comment
Question by:ben_stilwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 20343282
Isn't the concatenation operator for SQL the plus sign instead of the ampersand?
0
 

Author Comment

by:ben_stilwell
ID: 20343295
Still has the same error. I should have mention that this is a query being called from ASP, the ampersands would be used there, but the query as it is executed shouldn't contain them.
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 125 total points
ID: 20343302
[Student Number] should be `Student Number`
[Student ID] should be `Student ID`
[Course Number] should be `Course Number`

Im not familiar with access but in mysql you need to use backticks ``
0
 

Author Comment

by:ben_stilwell
ID: 20343315
Yep that was it. I knew it was something small.

Thanks.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question