Solved

You have an error in your SQL syntax

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…

705 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

16 Experts available now in Live!

Get 1:1 Help Now