Article View: borland.public.cppbuilder.database.dbexpress
Article #45Re: How to create (dynamically) a primary index with more than one field?
From: Minas
Date: Sun, 24 Jun 2007 08:22
Date: Sun, 24 Jun 2007 08:22
58 lines
2674 bytes
2674 bytes
Create a folder "C:\\TestDBTable" and
try a minimum piece of code.If the code is working
then you can add step by step additional fields in your table
TTable *table;
table=new TTable(NULL);
table->Active=false;
table->TableType=ttDefault;
table->TableType=ttParadox;
table->DatabaseName = "C:\\TestDBTable";
table->TableName= EditBDETableName->Text;
table->FieldDefs->Clear();
table->FieldDefs->Add("Id", ftString, 10, FALSE);
table->FieldDefs->Add("Remark", ftInteger, 0, FALSE);
table->FieldDefs->Add("State", ftString, 25, FALSE);
// ..... add additional fields here .......
table->IndexDefs->Clear();
table->IndexDefs->Add("", "Id;Remark",TIndexOptions()<<ixPrimary <<
ixUnique);
//table->IndexDefs->Add("StateX", "State",TIndexOptions()<<
ixCaseInsensitive);
table->CreateTable();
delete table;
You can use Database Explorer to verify the fields of
table Indices
Best Regards
_Minas Harokopos
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle
<MR> wrote
> How to create (dynamically) a primary index with *more than one
> field*?
>
> I tried the following:
>
> TTable *table;
> table=new TTable(NULL);
> table->Active=false;
> table->TableType=ttDefault; // uses adequate table-type (e.g.
> ttParadox, ttDBase) automatically, dependent on the file-extention
> table->TableType=ttParadox;
> table->TableName=EditBDETableName->Text;
> table->FieldDefs->Clear();
> table->FieldDefs->Add("Id", ftString, 10, FALSE);
> ...
> table->FieldDefs->Add("State", ftString, 25, FALSE);
> table->IndexDefs->Clear();
>
> and than
>
> table->IndexDefs->Add("", "Id;Remark",
> TIndexOptions()<<ixPrimary);
Technical Details
Message-ID:
<467e2a33@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<rf3n7353bhv32tvgdbcip16bgsbt0apt89@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: fb4e2,19b113387146ab80 X-Google-Attributes: gidfb4e2,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Minas" <no email> Newsgroups: borland.public.cppbuilder.database.dbexpress References: <rf3n7353bhv32tvgdbcip16bgsbt0apt89@4ax.com> Subject: Re: How to create (dynamically) a primary index with more than one field? Date: Sun, 24 Jun 2007 11:22:50 +0300 Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 77.49.47.62 Message-ID: <467e2a33@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1182673459 77.49.47.62 (24 Jun 2007 01:24:19 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail