I am currently developing a C# MySQL Export Utility. Due to this I am not going to know the fields or the data types of each field in the table.
When I export the data from the table in the database it displays a MySQLConversionException stating that it is unable to Covert MySQL Date/Time to System.DateTime. It was doing this when I ran the code:
if (!reader.isDBNull(fieldCount)){}
However, when the exception was thrown on this line I fixed it by adding Allow Zero DateTime=true to the MySQL Connection string but not it is displaying the error when I run the code
string value = reader.getString(field);
How can I get around this issue bearing in mind I am not going to know what data type is or what the value is going to be.
Thanks for any help you can provide.
You can get the raw value as object:
Then decide what to do based on its type:
Maybe not elegant, but should work.