Solved

Sample C code using CODEBASE  for reading .DBF file  requested please

Posted on 2008-10-30
6
1,050 Views
Last Modified: 2013-11-24
I have an inherited MS C development environment which I usually use for reading Btrieve files and writing out to dBase (.dbf) files; this is done by a prewritten function extractToDbase which uses Codebase.

I now have a need to read in one of these DBF files, update a field, then write out a new dbf file.

Unfortunately there is no prewritten function supplied for reading dBase files, my "skills" are no where near good enough for me to write one, and I can't find any Codebase manuals anywhere (locally or on the net).

Ideally I'd like to read in the dbf file using Codebase, but an alternative would be to unload the file to text first; either needs to be coded in C.

I would be very grateful if someone could post some sample code. Once I've got the gist of it, I should have no problem amending it to what I need.

Many thanks,
Rob
0
Comment
Question by:RClack
  • 4
  • 2
6 Comments
 
LVL 45

Assisted Solution

by:Kent Olsen
Kent Olsen earned 120 total points
ID: 22840773
Hi Rob,

It's not even that easy.  :(  There are several different formats for DBF files.  Competing products used the extension but had somewhat different formats.  Within a product line, a DBF file written for one version of the software is often incompatible with other versions.

What do you do with the DBF file once it's created?


Kent
0
 

Author Comment

by:RClack
ID: 22841430
Hi Kent,

The file is sent to users and probably viewed in Excel.

To give more indication on the format of the files, whenever I need to manually update these files I either use the dbu utility or I amend in Excel and then Save As DBF 3 (dBase III).

ROb
0
 

Author Comment

by:RClack
ID: 22841528
Hi Kent,

The file is sent to users and probably viewed in Excel.

To give more indication on the format of the files, whenever I need to manually update these files I either use the dbu utility or I amend in Excel and then Save As DBF 3 (dBase III).

If I can get started with the syntax then I'm hoping everything else will fall into place.

Rob

PS  "Ideally I'd like to read in the dbf file using Codebase, but an alternative would be to unload the file to text first; either needs to be coded in C."  Yes, I've just realised how silly that sounds as obviously I need to read the file in either situation!
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:RClack
ID: 22841800
I've read elsewhere that I could read it byte by byte as the dBase structure is published and relatively straight forward, so I guess that's another angle I can explore....
0
 
LVL 45

Assisted Solution

by:Kent Olsen
Kent Olsen earned 120 total points
ID: 22842149
This is going to be more than you wanted,  :),  but here's a DBF format description that should cover you.


http://www.clicketyclick.dk/databases/xbase/format/dbf.html#DBF_STRUCT


Kent
0
 

Accepted Solution

by:
RClack earned 0 total points
ID: 22842857
Thanks Kent,
I've come across several already but I like the way they have laid it out on that one!

I have come across a C program that I think I'll be able to amend to my purposes; see ftp://ftp.mpoli.fi/pub/software/PROGRAMM/C/DBASE.C, though my proxy would only allow me to view it through Google cache!

I'll come back to this on Monday to see if anyone actually comes back with some Codebase C coding, but I'll def award you points anyway for taking the trouble to help out.

Cheers,
Rob
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question