Page 1 of 1

Tinyint(1) maps to Int16

Posted: Thu 21 Dec 2006 17:31
by stevec
Many of my tables have TinyInt(1) columns. MySQLDirect maps this type to the CTS Int16 type.

I use the VS2005 DataSet Designer and GridViews in my projects. When I have a TinyInt(1) column in a table I want that it to appear as a Checkbox in my GridViews. To do this I change the DataType from Int16 to TinyInt(1) for the column in the DataSet designer, and it then automatically appears as a Checkbox. This works fine. The problem is if I make any changes to the TableAdaptor, such as adding a column, then the designer automatically adds a new column, naming it [originalcolumnname]1 with type Int16. It also unbinds the old column. I have to play around with the columns until I get it back to the way I want it. This is very time consuming, and frustrating.

My questions are:
(1) Is it possible to have TinyInt(1) columns automatically mapped to the Boolean type?
(2) If not, is there a way around what I am doing?

I could keep the column as Int16, and make the adjustments at the GridView level. But, it effectively causes me the same problem and takes even more time. If I refresh the DataSource schema of the GridView then I will have to convert the column to a checkbox again.

Any help would be greatly appreciated. Many thanks.

Posted: Thu 21 Dec 2006 18:12
by Yoohan
I'm experiencing the same issue. A simple work around is adding the columns manually which doesn't update the table adapter.

Posted: Fri 22 Dec 2006 10:14
by Alexey
Why don't you set the ColumnType of your tinyint column in the DataGridView to DataGridViewCheckBoxColumn?

Posted: Fri 22 Dec 2006 15:28
by rbirnesser
He is saying when he generates a dataset it maps the columns to int16 as the type. Could it be changed to map to boolean. Has nothing to do with the datagridview. Its really a pain if you have tons of tiny int columns in a large dataset.

Posted: Mon 25 Dec 2006 09:42
by Alexey
From MySQL AB:
Another extension is supported by MySQL for optionally specifying the display width of an integer value in parentheses following the base keyword for the type (for example, INT(4)). This optional display width specification is used to left-pad the display of values having a width less than the width specified for the column.
So tinyint(1) stores values -128 .. 127, and it cannot be mapped to the bool.

Posted: Wed 27 Dec 2006 19:00
by rbirnesser
So when the backend mysql database is a tinyint(1). When you generate a dataset using the xml schema designer you can't have it chang the mapped type to bool automatically instead of int(16) ?

Posted: Thu 28 Dec 2006 09:18
by Alexey
If we do like this, people using SByte type will suffer.

Posted: Fri 14 Mar 2008 16:14
by ashlar64
Having a similar prob. Was there a way to force the table or the DataView to map that particular column into a bool? If so what does that code look like?

Wasn't MySQL 5 supposed to support BOOLEANS? I go to the MySQL administrator it lets me alter columns to BOOLEANs but as soon as I exit and come back they are Tinyints again.....its really annoying.

Posted: Fri 14 Mar 2008 16:57
by Alexey.mdr
We cannot map TINYINT(1) to BOOL.
Because TINYINT(1) is represented as one byte in the MySQL server storage.
One bit is for the sign, another seven bits store the value itself.
You need to change the column type in the database in order to get a required boolean data type.