Skip to Content
avatar image
Former Member

Reading binary data from a character field using Advantage .Net Data Provider


I am working with ADS

I have a DBF database table which has been setup with a column of type character.

This field has been used to store binary data (compressed text actually).

Is it possible to read back this binary data using the Advantage .Net Data Provider?

The binary string is passed to a decompression library to return the original uncompressed ASCII text.

Here is a simplified version of the code :

AdsCommand cmd = new AdsCommand(.....);

cmd.CommandText = "Select Cast(TextField as Sql_Binary) as TextField From TextTable Where TextKey = ' 123' Order By LineId;";

AdsDataReader oReader = cmd.ExecuteReader();

if (oReader.Read())


// field must be read as binary, not string, ie include null values

oReader.GetBytes(0, 0, lineBuffer, 0, 255);


What I am finding is that lineBuffer will contain the start of the binary data, but as soon as the source data contains a null byte, every byte returned after that is also null.

If I open the DBF table in a binary editor application, I can see that the particular record definitely contains more data.

For example :

DBF Binary string as viewed directly in the file

01 02 10 04 20 55 00 10 20 30 55 66 90

C# byte buffer contents after calling oReader.Read()

01 02 10 04 20 55 00 00 00 00 00 00 00

Is there any combination of using Cast() or Convert() with AdsDataReader or AdsExtendedDataReader that will allow me to get the full raw contents of a character field from a DBF table?

I have tried several and can't seem to get past this hurdle.

At this point for the next step would be to move away from the .Net Data Provider completely. I have some other data access options which do allow access to the full raw record value which I believe are based on the older ACE client interface.

I was hoping to take a more modern approach with this project.


Kim Groves

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers