Solved

How to insert utf8 character in c# using ODBC

Posted on 2012-03-29
2
801 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

757 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

21 Experts available now in Live!

Get 1:1 Help Now