Greetings
I'm having some problems on my C# application. I'm using an access
database and I'm not able to do select queries with the ' character.
My code is this:
// some previous code like open connection
string sqlStatement="S ELECT oid FROM formatos WHERE formato='cd\\'s '";
myComm.CommandT ext=sqlStatemen t;
OleDbDataReader myDR=myComm.Exe cuteReader();
//... and so on
I get the exception message
AccessException : Syntax error (missing operator) in query expression
'formato='cd\'s ''.
DeclaringType.F ullName:: System.Data.Ole Db.OleDbCommand
Method - Void ExecuteCommandT extErrorHandlin g(Int32)
at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr)
at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior
behavior)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( )
at
....
AccessError: Syntax error (missing operator) in query expression
'formato='cd\'s ''.
Source: Microsoft JET Database Engine
Native Error: -524553244
State: 3075
How can I escape the ' and " chars so I can insert them onto an Access
database?
TIA
Lum
I'm having some problems on my C# application. I'm using an access
database and I'm not able to do select queries with the ' character.
My code is this:
// some previous code like open connection
string sqlStatement="S ELECT oid FROM formatos WHERE formato='cd\\'s '";
myComm.CommandT ext=sqlStatemen t;
OleDbDataReader myDR=myComm.Exe cuteReader();
//... and so on
I get the exception message
AccessException : Syntax error (missing operator) in query expression
'formato='cd\'s ''.
DeclaringType.F ullName:: System.Data.Ole Db.OleDbCommand
Method - Void ExecuteCommandT extErrorHandlin g(Int32)
at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr)
at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior
behavior)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( )
at
....
AccessError: Syntax error (missing operator) in query expression
'formato='cd\'s ''.
Source: Microsoft JET Database Engine
Native Error: -524553244
State: 3075
How can I escape the ' and " chars so I can insert them onto an Access
database?
TIA
Lum
Comment