Hi,

I am a csv file into a typed datset using the OLEDB provider. However
when the file is read into the dataset via the dataadapter fill method
my field lose there leading zeroes.

I have set the columns in the typed dataset to strings to avoid a
conversion to a numeric value but it seems to drop the zeroes anyway
before placing the data into the dataset.

I have tried using a schema.ini file which works if i pass the data
into a generic dataset but fails if i try to use my typed dataset.

I would have thought as I was using a typed dataset I would not need a
schema.ini anyway?

Any Ideas how to prevent the dropping of leading zeroes?

My code is as follows:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\CSVTest\\;Extended
Properties='text;HDR=Yes;FMT=Delimited;'";

System.Data.OleDb.OleDbConnection Conn = new
System.Data.OleDb.OleDbConnection(ConnectionString);

Conn.Open() ;

System.Data.OleDb.OleDbDataAdapter da = new
System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Test.csv", Conn) ;

//TestTypeDataset is a typed datset matching data in test.csv
TestTypeDataset FileResults = new FileResults;

da.Fill(FileResults, "FileData");

Conn.Close();


Thanks in advance.

Re: OleDbDataAdapter Losing Leading Zeros When importing csv into typed dataset by Paul

Paul
Thu Sep 01 07:33:30 CDT 2005

On 1 Sep 2005 00:11:08 -0700, jon.laing@gmail.com wrote:

¤ Hi,
¤
¤ I am a csv file into a typed datset using the OLEDB provider. However
¤ when the file is read into the dataset via the dataadapter fill method
¤ my field lose there leading zeroes.
¤
¤ I have set the columns in the typed dataset to strings to avoid a
¤ conversion to a numeric value but it seems to drop the zeroes anyway
¤ before placing the data into the dataset.
¤
¤ I have tried using a schema.ini file which works if i pass the data
¤ into a generic dataset but fails if i try to use my typed dataset.
¤
¤ I would have thought as I was using a typed dataset I would not need a
¤ schema.ini anyway?
¤
¤ Any Ideas how to prevent the dropping of leading zeroes?
¤

The leading zeroes are being dropped because the Text driver is interpreting the data type for the
column as numeric, which it essentially is. I don't know what your schema.ini file looks like but in
order to retain the leading zeroes you will have to define the column as text.

I don't know what the relationship would be between a strongly type DataSet and how the data is
interpreted by the Text driver. Is there a particular reason why you need to use a strongly typed
DataSet for your Text File?


Paul
~~~~
Microsoft MVP (Visual Basic)