[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Paul Clement

7/13/2004 7:02:00 PM

On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie@discussions.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@ameritech.net
Microsoft MVP (Visual Basic)
3 Answers

Paul Clement

7/14/2004 5:58:00 PM

0

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

¤
¤
¤ "Paul Clement" wrote:
¤
¤ > On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie@discussions.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@ameritech.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@ameritech.net
Microsoft MVP (Visual Basic)

=?Utf-8?B?RG91ZyBDb2xsaWU=?= <Doug

7/16/2004 12:38:00 AM

0

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:

> On Wed, 14 Jul 2004 00:18:02 -0700, "Doug Collie" <Doug Collie@discussions.microsoft.com> wrote:
>
> ¤
> ¤
> ¤ "Paul Clement" wrote:
> ¤
> ¤ > On Tue, 13 Jul 2004 03:22:01 -0700, "Doug Collie" <Doug Collie@discussions.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@ameritech.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@ameritech.net
> Microsoft MVP (Visual Basic)
>

Paul Clement

7/16/2004 6:21:00 PM

0

On Thu, 15 Jul 2004 15:38:01 -0700, "Doug Collie" <Doug Collie@discussions.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@ameritech.net
Microsoft MVP (Visual Basic)