Solved

How to insert utf8 character in c# using ODBC

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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn how to implement Singleton Design Pattern in Java.
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…

630 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