.NETGURU
reading dbf tables
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.odbcnet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Doug Collie (VIP)
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 to this message...
 
    
Paul Clement
On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Click here to reveal e-mail address> 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 ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
 
    
Doug Collie (VIP)
"Paul Clement" wrote:

[Original message clipped]

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 to this message...
 
    
Paul Clement
On Wed, 14 Jul 2004 00:18:02 -0700, "Doug Collie" <Doug Click here to reveal e-mail address> wrote:

¤
¤
¤ "Paul Clement" wrote:
¤
¤ > On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Click here to reveal e-mail address> 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 ~~~ Click here to reveal e-mail address
¤ > 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 ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
 
    
Doug Collie (VIP)
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:

[Original message clipped]

Reply to this message...
 
    
Paul Clement
On Thu, 15 Jul 2004 15:38:01 -0700, "Doug Collie" <Doug Click here to reveal e-mail address> 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 ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
 
 
System.Data.OleDb.OleDbConnection




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification