views:

99

answers:

1

Hello,

I've got problems with special characters being inserted and displayed properly. It's an ASP.NET 3.5 application (C#) and the database is MySql.

If I try to insert a special character into the database using a console app I get an error back saying 'Incorrect string value: '\x81 etc'. If I try to display them it displays for example ü instead of ü.

It works on my local machine, and the only difference I can find (and most likely the root of the problem) is that collation_server is set to latin1_swedish_ci on my machine, utf8_general_ci on the dev server, and character_set_server is latin1 on my machine, utf8 on the dev server. (Everything else is set to utf8 on both machines.)

I thought utf8 was the best thing to use, so now I'm not sure if I should change the dev server to be the same as my local machine which works, i.e. use latin, or change my local machine to be the same as the dev server and look for another solution to the problem? Any thoughts?

Thanks,

Annelie

+1  A: 

Set your connection string as follows:

"server=<server>;port=<port>;database=<db>;uid=<uid>;pwd=<password>;charset=utf8;"

Example:

"server=localhost;port=3306;database=mydb;uid=root;pwd=root;charset=utf8;"

(add charset=utf8 to it)

quantumSoup
Yessssss! That did the trick, thank you so much!
annelie