Solved

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

Posted on 2008-10-30
6
1,036 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Suggested Solutions

Title # Comments Views Activity
Microsoft Dynamics Roles question 4 85
Problem to scan all sheets 3 96
SCCM2012 sp2 CU3 cant see boot images missing tabs 3 60
Microsoft Access 2010 Question 2 63
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now