Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB & Excel

Status
Not open for further replies.

snakemaster

Programmer
May 10, 2001
6
NL
I'm trying to let VB extract data from an Excel file. For this I use the MS Jet OLE DB Provider. This works OK with most data. In one column however, I keep encountering the following problem.
The column is used to store dates. It can have two different formats "mm-dd-yy" and "dd/mm/yy". Only the first one is recognized as a date variable, the second one is stored as a Null value. Is it possible (for instance) in the extended properties to make VB read all values as string variables?
 
I'm curious where you're seeing the null value. Are you stepping through the code and seeing it, or are the values being written to a db or somewhere else?
 
In this article ( they explain how AD) deals with Excel.
"As stated previously, ADO must guess at the data type for each column in your Excel worksheet or range. (This is not affected by Excel cell formatting settings.) A problem can arise if you have numeric values mixed with text values in the same column. Both the Jet and the ODBC Provider return the data of the majority type, but return NULL (empty) values for the minority data type. If the two types are equally mixed in the column, the provider chooses numeric over text.

For example:
In your eight (8) scanned rows, if the column contains five (5) numeric values and three (3) text values, the provider returns five (5) numbers and three (3) null values.

In your eight (8) scanned rows, if the column contains three (3) numeric values and five (5) text values, the provider returns three (3) null values and five (5) text values.

In your eight (8) scanned rows, if the column contains four (4) numeric values and four (4) text values, the provider returns four (4) numbers and four (4) null values.
"
So if by chance (and this can change every month) I have six dates of "mm-dd-yy" and two of "mm/dd/yy" in the first eight rows, then ADO doesn't recognize "mm/dd/yy" as dates, but sees them as NULL values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top