tags:

views:

25

answers:

1

i am using windows forms application with MSAccess.... i got data from database table successfully but when i am trying to add data with (') character i got the exception that "OLEDB Exception: Syntax error(Missing Operator)inquery expression" ... Now how can i solve this problem? Plz tell me the solution of this problem....

all characters are accepted but apostrophe character only got error...

Thanks in Advance

+1  A: 

This is not realted to MsAccess - the ' is a string delimiter in SQL.

Look at the SQL satement you submit to the database and you will find out it may look something like

SELECT FROM Users WHERE NAME LIKE 'mc'donald'

and

'mc'donald'

has a ' too much.

You need to escape those ('mc''donald') OR - better - use parameters.

Also read up on SQL Injection Attacks - the basics there tell you a lot about how to properly deal with databases.

TomTom
Escape `'` characters in MS Access by doubling them up. Sending `'mc''donals'` will work. However TomTom is right, you should be using parameterized queries
Binary Worrier