1

My query to get a tinyint(1) field from a table in mysql in as below

mysqlcommand.selectquery="select vehicletype from vehicles where id=1"

possible values for vehicletype is 1 to 7

but the output in the datatable row for the field is shown as boolean

datatable dtresult;
mda.Fill(dtResult);
DataRow dr = dtResult.Rows[0];
//dr["vehicletype "]=false if 0
//dr["vehicletype "]=true if 1
//dr["vehicletype "]=true if 2
//dr["vehicletype "]=true if 3
//dr["vehicletype "]=true if 4 etc...

when i see the value of dr["vehicletype "] in visual studio it shows as false for 0 and true for any other value. How can i prevent it from default conversion

Saghir A. Khatri
  • 3,429
  • 6
  • 45
  • 76
sjd
  • 1,329
  • 4
  • 28
  • 48

1 Answers1

5

Refer to:

https://bugs.mysql.com/bug.php?id=67381

You can add to your connection string "Treat Tiny As Boolean=false;"

and now the tinyint will be interpreted like a type sbyte in C#.

Jano
  • 161
  • 1
  • 8