Hi.
I am using access(2003) db and there is a column that has "text" properties. I am trying to add a text with ( ' ) but I am getting unhandled error. How can i do that?
...
OleDbCommand cmd = new OleDbCommand(query,bag);
bag.Open();
cmd.ExecuteNonQuery();
Saving ' character to access db
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Roei BarRank #1,271 · 1.4K reputationPosted Sep 26, 2009, 1:18 PM EDT
string query = "INSERT INTO table (mtn_1) VALUES (['"+alt_mtn+"'])";
Roei BarRank #1,271 · 1.4K reputationPosted Sep 26, 2009, 9:31 AM EDT
To work arond this problem, do not use special characters. If you must use special characters in query expressions, enclose the special characters in brackets ([]). For example, if you want to use the greater than sign (>), use [>].
here is the KB on this issue from MS site
http://support.microsoft.com/kb/826763
Dushan Stankovic72 reputationPosted Sep 26, 2009, 9:45 AM EDT
yokzuRank #5,421 · 300 reputationPosted Sep 26, 2009, 12:26 PM EDT
string query = "INSERT INTO table (mtn_1) VALUES ('"+alt_mtn+"')";
I am assignning alt_mtn to a string text and it has ( ' ).