<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods > CreateNew |
Declaration
function CreateNew( sFileName: String;
iRdeType, iNumFields: Integer ): WordBool;
Description
Initializes a new work area. This is the first step in creating a new table. The second step is to define each field with iNumFields calls to CreateField. The final step is CreateExec, which physically creates the new table.
Parameters
sFileName: The DOS name of the new file qualified with a complete path and extension.
When working with a remote table via Apollo Database Server, you may only create new tables within the same Database directory as specified in the DatabaseName property of the TApolloTable component making this method call. The remote client cannot specify a physical server drive/path location and must use the defined server alias instead. Any physical drive/path included on the file sFileName parameter will be ignored for remote tables.
iRdeType: Use defined constants:
SDENTX 1 CA-Clipper compatible DBF-NTX driver
SDEFOX 2 FoxPro compatible DBF-IDX/CDX driver
SDENSX 3 HiPer-SIx DBF-NSX driver
iNumFields: The maximum number of fields to be added to the file structure via calls to CreateField.
Return Value
True if successful, False if creation failed.
Delphi Example
procedure TForm1.Button1Click(Sender: TObject);
begin
with ApTbl do
begin
if not CreateNew( 'c:\Apollo\Data\testnew.dbf', SDENSX, 5 ) then
begin
ShowMessage( 'Create failed' );
Exit;
end;
CreateField( 'fchar', 'C', 25, 0 );
CreateField( 'fnum', 'N', 10, 2 );
CreateField( 'flog', 'L', 1, 0 );
CreateField( 'fdate', 'D', 8, 0 );
CreateField( 'fmemo', 'M', 10, 0 );
if CreateExec then
ShowMessage( 'Create succeeded' )
else
ShowMessage( 'Create failed' );
end;
end;
C++Builder Example
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (!ApTbl->CreateNew( "c:\\Apollo\\Data\\testnew.dbf", SDEFOX, 5 ))
{
ShowMessage( "Create failed" );
return;
}
ApTbl->CreateField( "fchar", "C", 25, 0 );
ApTbl->CreateField( "fnum", "N", 10, 2 );
ApTbl->CreateField( "flog", "L", 1, 0 );
ApTbl->CreateField( "fdate", "D", 8, 0 );
ApTbl->CreateField( "fmemo", "M", 10, 0 );
if (ApTbl->CreateExec())
ShowMessage( "Create succeeded" );
else
ShowMessage( "Create failed" );
}
See Also
CreateExecCreateExec, CreateFieldCreateField, CREATE TABLE!JumpID(`APOLLOSQL.HLP',`CREATE_TABLE')