We think you have invalid data stored in your database.
We reproduced the problem when using mysql command line client to create and fill table. In this case data is stored in cp850 charset. When filling table with MySQLDirect .NET data is stored in latin1 (codepage 1252) charset and no error occurs.
Behaviour does not change if you alter storage option for table column (e.g. CHARACTER SET utf8 COLLATE utf8_general_ci). This means that problem is in data format.
To check that data inserted with MySQLDirect .NET is valid and recognized by server perform 'select upper(city) from afpe_organization' query. Data stored with MySQLDirect .NET will be returned in uppercase, data stored with mysql command line client will not. This means that server cannot identify characters in invalid codepage and does not perform uppercase transformation on some symbols.
We recommend you to fix the database. If this is impossible you can receive any charset data in the following way:
when using Unicode=false
Code: Select all
byte[] data = new byte[256];
int count = (int)reader.GetBytes(columnOffset, 0, data, 0, data.Length);
Console.WriteLine(Encoding.GetEncoding(850).GetString(data, 0, count));
when using Unicode=true
Code: Select all
byte[] data = new byte[256];
int count = (int)reader.GetBytes(columnOffset, 0, data, 0, data.Length);
string defaultString = Encoding.UTF8.GetString(data, 0, count);
byte[] cp850data = Encoding.Default.GetBytes(defaultString);
Console.WriteLine(Encoding.GetEncoding(850).GetString(cp850data));