Tinyint(1) maps to Int16

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
stevec
Posts: 2
Joined: Thu 21 Dec 2006 15:24

Tinyint(1) maps to Int16

Post by stevec » Thu 21 Dec 2006 17:31

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.

Yoohan
Posts: 2
Joined: Thu 21 Dec 2006 17:17
Location: Assen, The Netherlands

Post by Yoohan » Thu 21 Dec 2006 18:12

I'm experiencing the same issue. A simple work around is adding the columns manually which doesn't update the table adapter.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Fri 22 Dec 2006 10:14

Why don't you set the ColumnType of your tinyint column in the DataGridView to DataGridViewCheckBoxColumn?

rbirnesser
Posts: 37
Joined: Fri 11 Feb 2005 19:18

Post by rbirnesser » Fri 22 Dec 2006 15:28

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.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 25 Dec 2006 09:42

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.

rbirnesser
Posts: 37
Joined: Fri 11 Feb 2005 19:18

Post by rbirnesser » Wed 27 Dec 2006 19:00

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) ?

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Thu 28 Dec 2006 09:18

If we do like this, people using SByte type will suffer.

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Post by ashlar64 » Fri 14 Mar 2008 16:14

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.

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Fri 14 Mar 2008 16:57

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.

Post Reply