Reputation: 7674
I have an asp.net page connected to a MySql DB.
When I try to insert/update values from the webpage into the DB the chars are shown in the DB as question marks (I am using SP). If i will write a query directly in the DB, It will work and the chars will be displayed correctly.
The DB default charset is utf8, and the column collation is utf8_general_ci.
10x alot & Have a great weekend :)
Upvotes: 1
Views: 1092
Reputation: 7674
Eventually what solved my problem is adding CharSet=utf8 to the connection string.
10x alot everyone :)
Upvotes: 5
Reputation: 821
I believe your C# strings are being treated as unicode instead of UTF8
Some sample code from a snippet I had found some time ago:
System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;
// This is our Unicode string:
string s_unicode = "abcéabc";
// Convert a string to utf-8 bytes.
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s_unicode);
// Convert utf-8 bytes to a string.
string s_unicode2 = System.Text.Encoding.UTF8.GetString(utf8Bytes);
MessageBox.Show(s_unicode2);
Upvotes: 1