I have a MySQL Table, one of the columns' Data Type is TinyInt(1)
When I use this line of code it gives an error
int newNumber = int.Parse(string.Format("{0}", reader["someField"])
I think the reader is reading a bool value
however MySQL Table has row values of 0 & 1 & 6 & 7
so it is not bool true/false type
How can I actually grab that value to store into "int newNumber"
Thanks
David ChenPosted Aug 15, 2011, 2:22 PM
int newNumber = Convert.ToInt32(reader["abcd"]);
Console.WriteLine(newNumber);
print out 6
problem has to do with the select statement by adding " (newNumber+0)" then everything is ok
Sam HobbsPosted Aug 15, 2011, 12:19 AM
David ChenPosted Aug 15, 2011, 12:01 AM
Sam HobbsPosted Aug 14, 2011, 11:50 PM
David ChenPosted Aug 14, 2011, 11:15 PM
bool newNumber = (bool)reader["newField"]
newNumber returns false or true
thats because in that column I have 0, 1, 4, 6 ,7
David ChenPosted Aug 14, 2011, 10:57 PM
Sam HobbsPosted Aug 14, 2011, 10:13 PM
David ChenPosted Aug 14, 2011, 9:36 PM
Sam HobbsPosted Aug 14, 2011, 8:02 PM
You should determeine for sure what ype of data that reader["someField"] is. How is it defined for MySQL?