Hi All, I have a problem

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

Try using reader["someField"].GetInt32() . I'm not sure if the MySql connector supports indexed columns this way, so you may have to use reader.GetInt32(<column number of "someField">) i.e. reader.GetInt32(4) .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.