Solved

How to insert utf8 character in c# using ODBC

Posted on 2012-03-29
2
820 Views
Last Modified: 2012-05-15
Hello,

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.  

Thanks.
0
Comment
Question by:dev_meddiff
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37785826
convert it to byte array and store:-
byte [] UTF8encodes = UTF8Encoding.UTF8.GetBytes(source);

Here is how to store byte array to MySql:-
http://www.codeproject.com/KB/web-image/PicManager.aspx

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

Reference:-
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/bf68ddd8-3d95-4478-b84a-6570a2e20ae5
0
 
LVL 6

Expert Comment

by:effes
ID: 37797481
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").
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now