I am trying to make a program that prints the results of any sql query no matter what type the result has.
I am using a MySqlDataReader reader
. I already tried reader.GetValue(i)
, but it returns the error: unable to convert MySQL date/time value to System.DateTime
reader.GetString(i)
returns also errors when there are any non-string values.
reader[i].ToString()
internally uses GetValue()
and so returns the same error.
Inside of the MySqlDataReader
, there is a private function GetFieldValue(int index, bool checkNull)
which seems to have the wanted behavior, but I cannot access it.
I just want to read values like these exactly how they are stored:
ID | Date/Time | Name | Value |
---|---|---|---|
0 | 2024-09-03 12:01:23 | test | 0.00 |
But it either gives me errors, or if I use the GetValue(i) variant, it returns this:
ID | Date/Time | Name | Value |
---|---|---|---|
0 | 03.09.2024 12:01:23 | test | 0,00 |
So the date has a different format and floating point numbers use “,” instead of “.”
11