How to insert utf8 character in c# using ODBC


I am havig problem while inserting UTF8 characters in database using c# via ODBC connection, where database stores "?" for every utf8 character.

I have been able to save UTF8 characters using MYSQL Query Browser.

Platform details:
1. MySQL server 4.1
2. MySQL ODBC Connecter 3.51.12
3. .NET 2.0

Please suggest a correct way to do this.  

Who is Participating?
BuggyCoderConnect With a Mentor Commented:
convert it to byte array and store:-
byte [] UTF8encodes = UTF8Encoding.UTF8.GetBytes(source);

Here is how to store byte array to MySql:-

here is how to get string from byte array:-
string plainText = UTF8Encoding.UTF8.GetString(UTF8encodes);

Maybe your problem is the connection string. This post suggests that the entry for the encoding should be in lower case ("utf8" instead of "UTF8").
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.