Thursday, November 20, 2008

Storing Arabic (or Unicode) data in MySQL using Connector/Net 5.2

Storing Unicode data in varchar columns in MySQL can be tricky. I spent some time to use MySQL Connector/Net 5.2 to store Arabic data.
Once you know it, it's simple:

  • The varchar column Charset should be utf8
  • The varchar column Collate property should be utf8_general_ci. I tried utf8_bin and worked too. This is a screen shot from MySQL Administrator table editor:

  • In the .net application, the connection string must include charset=utf8. For example:



Anonymous said...

thanks it was helpfull for me

Anonymous said...

Thanks 1000 times, i was searching for this solution for the whole day.
that is what i called professional developer.

faheem said...

it works man
thanks (Y)

ansar said...

I am trying to save hindi words to mySQL using ASP.Net and also want to display it. I dont know how it is possible. As you said in your post, I have created a database and a field with utf8 as you mentioned. Then I just copy a hindi word and paste it into a textbox in Then I save this field into above field in the mySQL. When I go to database it is seen as ||||||. Can you give me a help for saving and display hindi words using and mySQL.

Ramzi Komati said...

It didn't work with me at all... I could store Arabic characters in the MySQL field but I couldnt read/write Arabic in the MySQL database from my ASP.Net files.

Ramzi Komati said...

I've been trying for severals days finding a solution for this problems. I tried using PHP and it works perfectly... I can read/write Arabic characters in/from MySQL database. However with ASP.Net I can't get it work!

Microsoft SQL is much more easier to read/write Arabic (and Hindi and other)characters in ASP.Net, by assigning the NVARCHAR data type.

So I'd recommend Ansar to store your information on MS SQL instead of MySQL for ASP.Net application.

Rajesh said...

Thanks, for the post , it really worked appending the database connection string with charset=utf8 and changing the mysql db schema to utf8 charset.

Anonymous said...

Thank you, it was helpfull for me

Majdi Aburahelah said...

Many thanks. it's solve my issue.

for IT the said...

This is an amazing blog,it gives very helpful messages to us.Besides that Wisen has established as Best Dot Net Training in Chennai. or learn thru ASP.NET Online Training . Nowadays Dot Net has tons of job opportunities on various vertical industry.

ASO Services said...

Thanks for your marvelous posting! It is very useful and good. Come on. I want to introduce the best aso services for you, I try it and I feel it is so good to rank app to top in app store search results, have you ever heard it?

Jagna Co Kalani said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP 7 Training in chennai | PHP 7 Training Course

PHP 7 Training in chennai | Online PHP 7 Course

Kayal m said...

Acually, I recently saw your post, This is very nice and I feel good to see your post. I am always following your blog, Continue posting...
Oracle DBA Training in Chennai
Oracle DBA Course in Chennai
Spark Training in Chennai
Pega Training in Chennai
Oracle Training in Chennai
Social Media Marketing Courses in Chennai
Excel Training in Chennai
Corporate Training in Chennai
Tableau Training in Chennai