escape the ' and " chars to insert them onto an Access database
From: Luminal (luminal_NOSPAM_at_hotpop_NOSPAM.com)
Date: 09/30/04
- Next message: Kelly: "Re: Error when trying to Inherit a control and then make it Serial"
- Previous message: Nicolas B: "is there a method to specify project option "Output File""
- Next in thread: Mythran: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: Mythran: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: James Curran: "Re: escape the ' and " chars to insert them onto an Access database"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Sep 2004 16:26:20 +0100
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="SELECT oid FROM formatos WHERE formato='cd\\'s'";
myComm.CommandText=sqlStatement;
OleDbDataReader myDR=myComm.ExecuteReader();
//... and so on
I get the exception message
AccessException: Syntax error (missing operator) in query expression
'formato='cd\'s''.
DeclaringType.FullName:: System.Data.OleDb.OleDbCommand
Method - Void ExecuteCommandTextErrorHandling(Int32)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.OleDb.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
- Next message: Kelly: "Re: Error when trying to Inherit a control and then make it Serial"
- Previous message: Nicolas B: "is there a method to specify project option "Output File""
- Next in thread: Mythran: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: Mythran: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: escape the ' and " chars to insert them onto an Access database"
- Reply: James Curran: "Re: escape the ' and " chars to insert them onto an Access database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|