views:

41

answers:

2

I've got a C# application which takes a users notes which can include various punctuation marks such as commas, apostrophes, semicolons etc.

At the moment I'm getting my application to encode the strings and storing them into the database as base 64.

Is there a better way?

FYI: I'm using a MySQL through their ODBC driver

+3  A: 

I'm guessing you are encoding them because the punctuation is causing your SQL update/insert to fail.

MySQL is more than capable of accepting punctuation so you need to find a different way.

Instead you should use parameterised queries which a) will allow you to use punctuation and b) avoid the much bigger issue of SQL injection attacks.

Have a look at this webpage which looks at querying your database but the same technique will work with inserts/updates

http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson06.aspx

CResults
A: 

If you use parameterized queries it will handle the encoding for you:

Parameterized Queries

derek