Groups | Blog | Home
all groups > vb.net data > october 2006 >

vb.net data : CSV conversion to DataSet converts decimal values to integer



Jo Goos
10/3/2006 8:15:02 AM
Hello,

I'm trying to solve an issue when reading a csv file into a dataset.

Suppose the next csv content :

Item,Value
Book,0
CD,0.52

When reading the csv content into the dataset, the 0.52 value is converted
to an integer value, because the first row does not contain a decimal value.

I'm using the next connection string ...
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & directory & ";Extended
Properties=Text;"

.... with an OleDBDataAdapter

Am I forgetting something in the connection string?

--
Kind regards,
Paul Clement
10/3/2006 11:41:10 AM
[quoted text, click to view]

¤ Hello,
¤
¤ I'm trying to solve an issue when reading a csv file into a dataset.
¤
¤ Suppose the next csv content :
¤
¤ Item,Value
¤ Book,0
¤ CD,0.52
¤
¤ When reading the csv content into the dataset, the 0.52 value is converted
¤ to an integer value, because the first row does not contain a decimal value.
¤
¤ I'm using the next connection string ...
¤ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & directory & ";Extended
¤ Properties=Text;"
¤
¤ ... with an OleDBDataAdapter
¤
¤ Am I forgetting something in the connection string?

No, but instead of allowing the Text ISAM driver to guess at the data type you will need to define
it in a schema.ini file.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp


Paul
~~~~
Jo Goos
10/4/2006 2:10:02 AM
Hello Paul,

Thnx for your quick answer.

I knew that solution, but I would like to avoid the use of the schema.ini
file since the procedure will be used by different types of (typed) datasets.
Isn't there another way to tell the OleDBAdapter to first check all rows
(and thus the column types) before creating the datatable?

--
Kind regards,
Jo Goos


[quoted text, click to view]
Paul Clement
10/4/2006 8:44:00 AM
[quoted text, click to view]

¤ Hello Paul,
¤
¤ Thnx for your quick answer.
¤
¤ I knew that solution, but I would like to avoid the use of the schema.ini
¤ file since the procedure will be used by different types of (typed) datasets.
¤ Isn't there another way to tell the OleDBAdapter to first check all rows
¤ (and thus the column types) before creating the datatable?

Unfortunately there isn't much choice. In the absence of a data type specification the Text driver
will guess at the data type depending upon the predominant values in the column. In your example the
predominant values (in the rows scanned) would appear to be integer instead of a floating point data
value.

You could try changing the MaxScanRows entry in the Registry to a value of zero (which is supposed
to cause a scan of the complete file) but I can't recall whether this was actually reliable.

HKEY_Local_Machine\Software\Microsoft\Jet\4.0\Engines\Text\MaxScanRows

MaxScanRows can also be used in a schema.ini file.


Paul
~~~~
AddThis Social Bookmark Button