I am using MySQL Connector/Net v.6.6.5 to pull data into my .Net application from a remote MySql database. One of the columns being read from the MySql database is a tinyint(1) data type containing values from 0-5. The problem is that the connector reads this column type as a bool (true/false) instead of an int. Thus, everything greater than 0 is returned as a one. This is a big problem. I don't have the luxury of altering the database column.
Below is the solution I ended up using. My original query was:
SELECT tinyint_column FROM table_with_a_tinyint
Using MySql.data.dll driver returns either TRUE or FALSE, which can easily be converted to a 1 or 0. But the data being read from the tinyint(1) column contained 0-5. I was able to extract the correct values by editing my query to below:
SELECT (tinyint_column+0) FROM table_with_a_tinyint
This yielded the correct values (0-5) from the MySql tinyint column. Hopefully it will help someone in the same situation in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With