Solved

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

Posted on 2008-10-30
6
1,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

756 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