Article ID: 113877
Article Last Modified on 5/6/2003
APPLIES TO
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
This article was previously published under Q113877
Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
Btrieve database files (which usually have .DAT extensions) consist of a header page, multiple index pages, and multiple data pages. With the exception of index fields located in the header page, none of these items include any information about the data types or the locations of the fields in the Btrieve database file. Also, while the header page contains information about the number and types of indexes, it does not contain any information about the non-index parts of the record. Because Microsoft Access and Microsoft Visual Basic require specific information about each field, they must use .DDF files, which contain the databases' data dictionary information, to obtain this information.
MORE INFORMATION
There are seven available .DDF files: FILE.DDF, FIELD.DDF, INDEX.DDF, ATTRIB.DDF, VIEW.DDF, USER.DDF, and RIGHTS.DDF. Microsoft Access version 2.0 requires only FILE.DDF and FIELD.DDF. Microsoft Access can maintain the INDEX.DDF file for interoperability with Xtrieve, but the default is not to maintain it.
When you are using .DDF files with Microsoft Access, bear the following in mind:
- Each file must use one of the seven names listed above, without any variation. For example, substituting FILE1.DDF for FILE.DDF will not work.
- All the files must be in the same directory.
If either of these criteria are not met, Microsoft Access will not be able to use the files and errors may occur.
Each Btrieve database file (.DAT file) contains only one table. Therefore, a Btrieve application may have several .DAT files
File Definitions
FILE.DDF:
The FILE.DDF file contains the following elements:
- The file ID number.
- The table name.
- The path to the file (including filename).
- The file-type identifier.
A sample FILE.DDF might look like:
Xf$ID Xf$Name Xf$Loc Xf$Flags -------------------------------------------------- 1 x$File C:\MYDIR\FILE.DDF 16 2 x$Field C:\MYDIR\FIELD.DDF 16 3 x$Index C:\MYDIR\INDEX.DDF 16 4 TestFile TEST.DAT 0 5 Datafile Q:\PUBLIC\DATA.DAT 0 6 MyData MOREDATA\MYDATA.BTV 0
The sample FILE.DDF file above indicates that the FILE.DDF, FIELD.DDF, and INDEX.DDF files (file numbers 1, 2, and 3) are in the directory C:\MYDIR. The entry in the Xf$Flags column (16) indicates that these files are system files that are used to locate other system files.
NOTE: Xtrieve uses the paths listed in the FILE.DDF file to search for these system files. Microsoft Access, however, only looks for these files in the same directory where the FILE.DDF file was found.
File numbers 4, 5, and 6 contain information on three Btrieve database files that can be used by Microsoft Access as attached tables. The entry in the Xf$Flags column (0) indicates that these are user-defined files.
File number 4, TestFile, does not have a path specified. Therefore, Microsoft Access will search for this file in the directory in which it found the FILE.DDF file.
File number 5, DataFile, has a drive and path specified. Microsoft Access will search the specified drive and path for the file.
File number 6, MyData, has a path but no drive specified. Microsoft Access will search for this file in the MOREDATA subdirectory of the directory in which it found the FILE.DDF file.
The specifications for the FILE.DDF file are:
FieldName Description DataType Position Length ----------------------------------------------------------- Xf$ID File ID Integer 1 2 Xf$Name File Name String 2 20 Xf$Loc File Location String 23 64 Xf$Flags File Flags* Integer 87 1
- If bit 4 equals 1, the file is a dictionary (.DDF) file. If bit 4 equals 0, the file is a user-defined file.
The "Xf$" prefixes are part of the Novell definition for these files.
Position is the offset from the beginning of the column, and Length is the length of the field.
FIELD.DDF:
The FIELD.DDF file contains:
- The ID number.
- The file ID number (this is cross-referenced to FILE.DDF).
- The field name (the column name in Microsoft Access).
- The data type.
- The offset.
- The size.
- The number of decimal places.
- A case-sensitive flag.
A sample FIELD.DDF file might look like:
Xe$Id Xe$File Xe$Name Xe$DataType Xe$Offset Xe$Size Xe$Dec Xe$Flags ------------------------------------------------------------------- 1 1 Xf$Id 1 0 2 0 0 2 1 Xf$Name 0 2 20 0 0 3 1 Xf$Loc 0 22 64 0 0 4 1 Xf$Flags 1 86 1 0 0 5 2 Xe$Id 1 0 2 0 0 6 2 Xe$File 1 2 2 0 0 7 2 Xe$Name 0 4 20 0 0 8 2 Xe$DataType 1 24 1 0 0 9 2 Xe$Offset 1 25 2 0 0 10 2 Xe$Size 1 27 2 0 0 11 2 Xe$Dec 1 29 1 0 0 12 2 Xe$Flags 1 30 2 0 0 13 3 Xi$File 1 0 2 0 0 14 3 Xi$Field 1 2 2 0 0 15 3 Xi$Number 1 4 2 0 0 16 3 Xi$Part 1 6 2 0 0 17 3 Xi$Flags 1 8 2 0 0 18 4 nCounter 1 0 4 0 1 19 4 stUnique 0 4 15 0 1 20 4 stDup 0 19 15 0 1 21 4 rNumb 2 34 4 0 0 22 5 nCustNumb 1 0 4 0 0 23 5 stName 0 4 15 0 1 24 5 stAddress 0 19 20 0 1 25 5 stCity 0 39 20 0 1 26 6 nCustNumb 1 1 4 0 0 27 6 rBalanceDue 1 1 8 0
This file contains actual field definitions. The first 17 rows contain the description of each field in FILE.DDF, FIELD.DDF (self-describing), and INDEX.DDF. The definitions are related to the FILE.DDF file by the Xe$File field, which correlates to the Xf$ID field in FILE.DDF. Thus, the first 4 records are for file number 1, which in FILE.DDF is FILE.DDF, the next 8 records are for file number 2, which in FILE.DDF is FIELD.DDF, and 5 records are for file number 3, INDEX.DDF.
Note that the records do not have to be in this order, or have to contain these file numbers, although they usually do. Some .DDF builders will put them in order, others do not. However, the records in FIELD.DDF must be in the same order as the fields within the file they describe. For example, the first record in FIELD.DDF for file number 1 must describe the first field in file number 1, and so on.
In this example, file number 4, TEST.DAT in FILE.DDF, has 4 fields:
- nCounter: a Long (4-byte) Integer with an offset of 0.
- stUnique: a 15-byte String with an offset of 4.
- stDup: a 15-byte String with an offset of 19.
- rNumb: a 4-byte Real with an offset of 34.
Note that file number 6 (MyData) contains an 8-byte integer named rBalanceDue. This is a Visual Basic Currency data type and is passed directly through to Microsoft Access unchanged.
If any of the fields were of the Btrieve Numeric type, the Xe$Dec field would contain the number of decimal points.
The specifications for FIELD.DDF are:
FieldName Description DataType Position Length ---------------------------------------------------------- Xe$ID Field Id Integer 1 2 Xe$File File Id from Integer 3 2 FILE.DDF Xe$Name FieldName String 5 20 Xe$DataType Btrieve Integer 25 1 DataType Xe$Offset Offset Integer 26 2 Xe$Size Field size Integer 28 2 Xe$Dec Decimal places Integer 30 1 Xe$Flags Bit0=Case flag Integer 31 2 for strings
The "Xe$" prefix is part of the Novell definition for these files.
Btrieve is manufactured by Pervasive Software and Xtrieve is manufactured by Novell Inc., vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.
Additional query words: importing exporting linking attaching
Keywords: kbinfo kb3rdparty KB113877