buffer too small...
Posted: Sat 21 Nov 2009 19:49
I have a database with text fields which stores Chinese text. The connection already uses "unicode=true". In MySQL, the field uses UTF-8 charset.
And the code has no problem with retrieving data.
When I update the text, with a very simple update statement:
UPDATE book SET long_desc='a long text here' WHERE id = '10874'
It gives me an exception if the string is long: "The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes"
This is my code:
DbCommand command = mConnection.CreateCommand();
command.CommandText = inCommand;
int affected = command.ExecuteNonQuery();
command.Dispose();
return affected;
And the code has no problem with retrieving data.
When I update the text, with a very simple update statement:
UPDATE book SET long_desc='a long text here' WHERE id = '10874'
It gives me an exception if the string is long: "The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes"
This is my code:
DbCommand command = mConnection.CreateCommand();
command.CommandText = inCommand;
int affected = command.ExecuteNonQuery();
command.Dispose();
return affected;