Board index » cppbuilder » Creating dbf file

Creating dbf file


2004-09-30 10:55:27 PM
cppbuilder93
Hi,
I hope this is the correct database subgroup for this question
I am using BCB5 and Windows 98SE
Having difficulties finding a way to create a dbf file without spending on some third party all included .....
I would like to be able to have the user enter the data (EditBox...) and the program to create a seperate data file of type dbf.
The file to be created is to be used by another app.
I require two columns, and unknows rows, an example with two
rows of data:
Part Quantity
123456 100
654321 25
The file that was created by the other app looks like:
0: 03 68 09 1D 04 00 00 00 61 00 29 00 00 00 00 h
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....
through a text editor program
Any Ideas?
Thanks in Advance
Andrew
 
 

Re:Creating dbf file

Hello Andrew,
Look for "TTable::CreateTable" method in the C++Builder help file. The
example it has works very fine.
HTH
Jayme.
"Andrew McIsaac" < XXXX@XXXXX.COM >escreveu na mensagem
Quote

Hi,
I hope this is the correct database subgroup for this question
I am using BCB5 and Windows 98SE

Having difficulties finding a way to create a dbf file without spending on
some third party all included .....

I would like to be able to have the user enter the data (EditBox...) and
the program to create a seperate data file of type dbf.

The file to be created is to be used by another app.
I require two columns, and unknows rows, an example with two
rows of data:
Part Quantity
123456 100
654321 25

The file that was created by the other app looks like:
0: 03 68 09 1D 04 00 00 00 61 00 29 00 00 00 00 h
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....
through a text editor program

Any Ideas?

Thanks in Advance
Andrew



 

Re:Creating dbf file

Thanks to Jayme for the respose,
I tried the example of
"TTable::CreateTable" method in the C++Builder help file.
I created a standard button Click event, then pasted the
entire example within the Button1Click Event.
if (!Table1->Exists) // Don't overwrite an existing table
{
.
.
.
TFieldDef *pNewDef = Table1->AddFieldDef();
.
.
.
Table1->CreateTable();
}
This fails for me
Error : AddFieldDef() is not a member of TTable.
Have I missed a step along the way?
Thanks
Andrew
 

{smallsort}

Re:Creating dbf file

Hello Andrew,
I'm sorry. As you can check in the help file there is a mistake
in the suplied code, the help file was not updated to the
C++Builder 5.0 version, the example is perfect for the v.3.0.
You only have to insert the TTable::FieldDefs property which
has the AddFieldDef() method instead of TTable , so :
TFieldDef *pNewDef = Table1->FieldDefs->AddFieldDef();
will works fine.
The code bellow I'm using in one of my applications :
.....
TbAux->TableType = ttParadox ;
// Fields Definition
TbAux->FieldDefs->Clear();
fldDef = TbAux->FieldDefs->AddFieldDef();
fldDef->Name = "MunicipioAtendido" ;
fldDef->DataType = ftAutoInc ;
fldDef->Required = false;
fldDef = TbAux->FieldDefs->AddFieldDef();
fldDef->Name = "Data" ;
fldDef->DataType = ftDate ;
fldDef->Required = true;
..... more fields
// Indexes definition
TbAux->IndexDefs->Clear();
Options.Clear(); Options << ixPrimary << ixUnique;
TbAux->IndexDefs->Add("","MunicipioAtendido", Options);
Options.Clear(); Options << ixDescending << ixCaseInsensitive;
TbAux->IndexDefs->Add("MunAtMun","Municipio;Data;MunicipioAtendido",
Options);
TbAux->IndexDefs->Add("MunAtAli","Equipamento;Data;MunicipioAtendido",
Options);
// Create command
TbAux->CreateTable();
.....
HTH
Jayme.
"Andrew McIsaac" < XXXX@XXXXX.COM >escreveu na mensagem
Quote

Thanks to Jayme for the respose,

I tried the example of
"TTable::CreateTable" method in the C++Builder help file.
I created a standard button Click event, then pasted the
entire example within the Button1Click Event.

if (!Table1->Exists) // Don't overwrite an existing table
{
.
.
.
TFieldDef *pNewDef = Table1->AddFieldDef();
.
.
.
Table1->CreateTable();
}

This fails for me
Error : AddFieldDef() is not a member of TTable.
Have I missed a step along the way?

Thanks
Andrew