We help IT Professionals succeed at work.
Get Started

Incorrect data type when importing Excel into data table

Last Modified: 2012-05-12
I am importing an Excel file into a data table via OleDBDataAdapter.  I then process the new data table for data validation.  The problem is that during the oledb import  the data type for a column is automatically set to 'double' if the column data happens to contain numeric data.  In my case, all rows in that column are NULL except for two - one contains text and the other is all numeric.  For some reason, the data for that column is determined to be 'double'.  All columns are assumed to be 'text'.  This poses a problem when I do my validation because I am comparing the value to an expected text value which throws an error saying that the column is expected to be of type 'double'.

Following (or during) the oledb import into the data table, is there some way I can force all columns to be 'text' before I begin my validation process?
Watch Question
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE