Tinyint(1) maps to Int16

Tinyint(1) maps to Int16

Postby 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.
stevec
 
Posts: 2
Joined: Thu 21 Dec 2006 15:24

Postby 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.
Yoohan
 
Posts: 2
Joined: Thu 21 Dec 2006 17:17
Location: Assen, The Netherlands

Postby Alexey » Fri 22 Dec 2006 10:14

Why don't you set the ColumnType of your tinyint column in the DataGridView to DataGridViewCheckBoxColumn?
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby 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.
rbirnesser
 
Posts: 37
Joined: Fri 11 Feb 2005 19:18

Postby 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.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby 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) ?
rbirnesser
 
Posts: 37
Joined: Fri 11 Feb 2005 19:18

Postby Alexey » Thu 28 Dec 2006 09:18

If we do like this, people using SByte type will suffer.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby 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.
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Postby 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.
Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24


Return to dotConnect for MySQL