Solved

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

Posted on 2008-10-30
6
1,042 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:Kdo
Kdo 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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:Kdo
Kdo 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

810 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