Zerofill columns

Zerofill columns

Postby trygvelo » Fri 03 Jul 2009 08:04


I've got several fields where I need to save fixed length numeric only data. I followed the mysql recommendation and created these fields as f.ex int(4) unsigned zerofill for a 4 digit numeric field. I tried filling a typed dataset table with this column with a value of 0012 in db. The value when using datatable column type to System.int32 leaves a 12 in the dataset, if setting dataset column type to System.String it still gives me a value of 12, not 0012 as I would expect.

I had to revert to using char(4) in the database for this to work. What is the reason the int(4) unsigned zerofill doesn't work when reading it from db to a datatable in a typed dataset? Is it dotConnect or the DataSet design that is to blame?
Posts: 13
Joined: Wed 19 Jan 2005 10:53

Postby Shalex » Fri 03 Jul 2009 11:03

This is a designed behaviour. Please use the select statement in the typed Devart DataSet as follows:
Code: Select all
SELECT cast(int4column as char(4)) FROM mytable

The result column from this select statement will be mapped to System.String and will show 0012.
Devart Team
Posts: 7391
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for MySQL