TEXT field returns System.Byte[] in ToString()
Brought to you by:
ultralight32
With a MySQL TEXT field, calling:
MySQLDataReader["FieldName"].ToString()
returns System.Byte[] instead of the actual string
value.
A work-around is to instead call:
strValue = MySQLDataReader.GetString
(MySQLDataReader.GetOrdinal("FieldName"));
The previous version of MySQLDriverCS correctly
converted ToString() for a TEXT field. However, the
new version fails to do this. This should be brought
back into ToString().
Logged In: NO
Where is old version?
I have same error with you.
Logged In: NO
I believe to correct this, you need to edit C:\Program
Files\MySQLDriverCS\source\MySQLDriverCS\MySQLDataReader.cs
in Visual Studio and set the following function shown
below. Then do a rebuild-all and include the new .dll file
in your project. The dll is located in C:\Program
Files\MySQLDriverCS\dll\MySQLDriverCS.dll
public string GetString( int i )
{
//Convert Text field to string
if (this[i] is byte[])
{
return System.Text.Encoding.Default.GetString((byte
[])this[i]);
}
else
{
return Convert.ToString( this[i] );
}
}
Logged In: YES
user_id=1460953
Sorry, forgot to login. I posted the solution code below.