Re: Stop assuming data types!!!

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Luke R" <dont@xxxxxxx> wrote in message
news:7A08D140-28BF-4BB7-BCC8-6E8F9C04BBF7@xxxxxxxxxxxxxxxx
Arghh this is so frustrating.

The following peice of code populates a dataset from a tab delimited text
file;
MyConnection = New
System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data
source=" & xFile.DirectoryName & "; Extended
Properties=""text;FMT=Delimited""")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select *
from " & xFile.FullName, MyConnection)
MyCommand.Fill(DS)
MyConnection.Close()

Nice and simple.

I have a column called Item Number. The first 30 rows of 'Item Number' are
actual numbers. The remaining 40 contain non-numeric characters.

The problem is that in the dataset that is returned, the 'Item Number'
column is numeric, despite the fact that it clearly is not numeric because
it contains non-numeric characters. It just seems to look at the first
value and assume it from there.

This results in the remaining 40 rows that contain non-numeric values for
'Item Number' return null.

What a crock. Can anyone PLEASE help!

Unless you have a schema file the text drivers will look at the first couple
of rows to determine the data types for the columns. You need to read up on
creating a schema file for your text file.

--
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


.