Solved

You have an error in your SQL syntax

Posted on 2007-11-24
4
186 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now