Solved

How to insert utf8 character in c# using ODBC

Posted on 2012-03-29
2
853 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

738 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