Setting DataTable column type does not persist to MS Excel

Asked By David Sharp
01-Feb-10 01:56 PM
Earn up to 0 extra points for answering this tough question.

I am using the MS Jet driver 4.0 to export a .dbf file and its associated .dbt file. The problem I am having is that even after several hours of searching, the data in my columns are all "memo fields," meaning they are all strings/text. Since this is the case, I cannot add up any numeric values, as they are seen as text and will print a SUM of 0. I have tried multiple ways of setting the column type as follows, but none of them appear to have any effect on the output...they are still text values.

 

DataTable.Columns.Add(COL_HRS, typeof(System.Double)); 

stream.DataTable.Columns.Add(COL_HRS), Type.GetType("System.Double"));

...etc.

 

Is this a problem with the MS 4.0 Jet Driver? Has anyone else ran into this? Thanks in advance.

  Microsoft dBase Driver connection string

Robbe Morris replied to David Sharp
01-Feb-10 02:47 PM

I don't have a complete sample.  I dug this out of a 10 year old VB 6.0 app that worked heavily with dbf files.  I use to use classic ADO with the Microsoft dbase driver.  Here is the connection string:

"DBQ=" & sDBPath & ";Driver={Microsoft dBase Driver (*.dbf)};DriverId=277;FIL=dBase4.0"

This "might" work with the .NET Odbc classes and "might" work better than the Jet provider.

  re: Microsoft dBase Driver connection string

David Sharp replied to Robbe Morris
01-Feb-10 06:43 PM

Robbe,

It seems reasonable that using the dBase driver has the potential to solve the problem. Currently, I'm working on using the Visual FoxPro driver to solve it also. Unfortunately, I feel like these could be work-arounds to the real problem, unless there's something I'm just missing.

Create New Account