0

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

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Parameterized Queries

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.