HighTechTalks DotNet Forums  

reading dbf tables

Dotnet Framework (ODBC.net) microsoft.public.dotnet.framework.odbcnet


Discuss reading dbf tables in the Dotnet Framework (ODBC.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Doug Collie
 
Posts: n/a

Default reading dbf tables - 07-13-2004 , 06:22 AM






I have an interesting problem reading data from a dbf table

I can create a dbf table in excel, save it then use odbc in .net to read it - ok.

I can read the same table in another (3rd party) app ok.
If I change data in the table using the 3rd party app the table structure changes.
Excel reads the modified table ok, the 3rd party app reads it ok but .net returns enpty objects.

The problem appears to be that the (numeric) data is initially right justified in the dbf, but the 3rd party app left justifies it.

I can't do anything about the 3rd party app, and need to use it ars it is. I can't find any info suggesting that dbf has a standard.

Any suggestions how I can force .net to read the left justified numeric field?

Thanks


Reply With Quote
  #2  
Old   
Paul Clement
 
Posts: n/a

Default Re: reading dbf tables - 07-13-2004 , 01:02 PM






On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:

¤ I have an interesting problem reading data from a dbf table
¤
¤ I can create a dbf table in excel, save it then use odbc in .net to read it - ok.
¤
¤ I can read the same table in another (3rd party) app ok.
¤ If I change data in the table using the 3rd party app the table structure changes.
¤ Excel reads the modified table ok, the 3rd party app reads it ok but .net returns enpty objects.
¤
¤ The problem appears to be that the (numeric) data is initially right justified in the dbf, but the 3rd party app left justifies it.
¤
¤ I can't do anything about the 3rd party app, and need to use it ars it is. I can't find any info suggesting that dbf has a standard.
¤
¤ Any suggestions how I can force .net to read the left justified numeric field?

I doubt that the field being displayed as justified has anything to do with the how it's stored. How
are you attempting to retrieve the data from the dfb? Is this a dBase database?


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

Reply With Quote
  #3  
Old   
Doug Collie
 
Posts: n/a

Default Re: reading dbf tables - 07-14-2004 , 03:18 AM





"Paul Clement" wrote:

Quote:
On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:

¤ I have an interesting problem reading data from a dbf table
¤
¤ I can create a dbf table in excel, save it then use odbc in .net to read it - ok.
¤
¤ I can read the same table in another (3rd party) app ok.
¤ If I change data in the table using the 3rd party app the table structure changes.
¤ Excel reads the modified table ok, the 3rd party app reads it ok but .net returns enpty objects.
¤
¤ The problem appears to be that the (numeric) data is initially right justified in the dbf, but the 3rd party app left justifies it.
¤
¤ I can't do anything about the 3rd party app, and need to use it ars it is. I can't find any info suggesting that dbf has a standard.
¤
¤ Any suggestions how I can force .net to read the left justified numeric field?

I doubt that the field being displayed as justified has anything to do with the how it's stored. How
are you attempting to retrieve the data from the dfb? Is this a dBase database?


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

The problem appears to be exactly how it is stored in the dbf file.

Using a binary read of the file, the dbf is structured with numeric fields (N specifier) of width 15. The version that works has the padding spaces to the left of the data in the field, the one that doesn't has the padding to the right.

..net reads the data ok if I change the field specifier in the dbf to character (C specifier). But clearly I don't want to start modifying a file that I treat as read-only.

They are dbase4 format (but actually very basic in structure - 2 numeric cols, no memos etc)



Reply With Quote
  #4  
Old   
Paul Clement
 
Posts: n/a

Default Re: reading dbf tables - 07-14-2004 , 11:58 AM



On Wed, 14 Jul 2004 00:18:02 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:

¤
¤
¤ "Paul Clement" wrote:
¤
¤ > On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:
¤ >
¤ > ¤ I have an interesting problem reading data from a dbf table
¤ > ¤
¤ > ¤ I can create a dbf table in excel, save it then use odbc in .net to read it - ok.
¤ > ¤
¤ > ¤ I can read the same table in another (3rd party) app ok.
¤ > ¤ If I change data in the table using the 3rd party app the table structure changes.
¤ > ¤ Excel reads the modified table ok, the 3rd party app reads it ok but .net returns enpty objects.
¤ > ¤
¤ > ¤ The problem appears to be that the (numeric) data is initially right justified in the dbf, but the 3rd party app left justifies it.
¤ > ¤
¤ > ¤ I can't do anything about the 3rd party app, and need to use it ars it is. I can't find any info suggesting that dbf has a standard.
¤ > ¤
¤ > ¤ Any suggestions how I can force .net to read the left justified numeric field?
¤ >
¤ > I doubt that the field being displayed as justified has anything to do with the how it's stored. How
¤ > are you attempting to retrieve the data from the dfb? Is this a dBase database?
¤ >
¤ >
¤ > Paul ~~~ pclement (AT) ameritech (DOT) net
¤ > Microsoft MVP (Visual Basic)
¤ >
¤
¤ The problem appears to be exactly how it is stored in the dbf file.
¤
¤ Using a binary read of the file, the dbf is structured with numeric fields (N specifier) of width 15. The version that works has the padding spaces to the left of the data in the field, the one that doesn't has the padding to the right.
¤
¤ .net reads the data ok if I change the field specifier in the dbf to character (C specifier). But clearly I don't want to start modifying a file that I treat as read-only.
¤
¤ They are dbase4 format (but actually very basic in structure - 2 numeric cols, no memos etc)

Well it's possible that the driver you are using doesn't support the field specifier. I still don't
know which driver you are using or how you are pulling in the data.


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

Reply With Quote
  #5  
Old   
Doug Collie
 
Posts: n/a

Default Re: reading dbf tables - 07-15-2004 , 06:38 PM



I connect to the table using a .net odbc data adapter - with the dsn file created by the .net connection wizard to connect to dbaseIV (it looks pretty basic with no obvious data control options)

Data is then loaded to an internal Dataset (fillschema and fill).

I then probe the data using a ->select() statement to extract all the rows to a datarow array, and probe the columns through the data row column->Item method. The resultant Object is a blank string.

The connection method works ok if I manually change the data type to Character and it also operates on Numeric data cols if they are right justified in the table.



"Paul Clement" wrote:

Quote:
On Wed, 14 Jul 2004 00:18:02 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:

¤
¤
¤ "Paul Clement" wrote:
¤
¤ > On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:
¤
¤ > ¤ I have an interesting problem reading data from a dbf table
¤ > ¤
¤ > ¤ I can create a dbf table in excel, save it then use odbc in .net to read it - ok.
¤ > ¤
¤ > ¤ I can read the same table in another (3rd party) app ok.
¤ > ¤ If I change data in the table using the 3rd party app the table structure changes.
¤ > ¤ Excel reads the modified table ok, the 3rd party app reads it ok but .net returns enpty objects.
¤ > ¤
¤ > ¤ The problem appears to be that the (numeric) data is initially right justified in the dbf, but the 3rd party app left justifies it.
¤ > ¤
¤ > ¤ I can't do anything about the 3rd party app, and need to use it ars it is. I can't find any info suggesting that dbf has a standard.
¤ > ¤
¤ > ¤ Any suggestions how I can force .net to read the left justified numeric field?
¤
¤ > I doubt that the field being displayed as justified has anything to do with the how it's stored. How
¤ > are you attempting to retrieve the data from the dfb? Is this a dBase database?
¤
¤
¤ > Paul ~~~ pclement (AT) ameritech (DOT) net
¤ > Microsoft MVP (Visual Basic)
¤
¤
¤ The problem appears to be exactly how it is stored in the dbf file.
¤
¤ Using a binary read of the file, the dbf is structured with numeric fields (N specifier) of width 15. The version that works has the padding spaces to the left of the data in the field, the one that doesn't has the padding to the right.
¤
¤ .net reads the data ok if I change the field specifier in the dbf to character (C specifier). But clearly I don't want to start modifying a file that I treat as read-only.
¤
¤ They are dbase4 format (but actually very basic in structure - 2 numeric cols, no memos etc)

Well it's possible that the driver you are using doesn't support the field specifier. I still don't
know which driver you are using or how you are pulling in the data.


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)


Reply With Quote
  #6  
Old   
Paul Clement
 
Posts: n/a

Default Re: reading dbf tables - 07-16-2004 , 12:21 PM



On Thu, 15 Jul 2004 15:38:01 -0700, "Doug Collie" <Doug Collie (AT) discussions (DOT) microsoft.com> wrote:

¤ I connect to the table using a .net odbc data adapter - with the dsn file created by the .net connection wizard to connect to dbaseIV (it looks pretty basic with no obvious data control options)
¤
¤ Data is then loaded to an internal Dataset (fillschema and fill).
¤
¤ I then probe the data using a ->select() statement to extract all the rows to a datarow array, and probe the columns through the data row column->Item method. The resultant Object is a blank string.
¤
¤ The connection method works ok if I manually change the data type to Character and it also operates on Numeric data cols if they are right justified in the table.
¤

Have you tried using Jet OLEDB with the dBase ISAM driver?

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\dBase;Extended Properties=dBase IV"

Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )

dBaseConnection.Open()

Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.