Board index » cppbuilder » Column error

Column error


2004-09-17 12:44:55 AM
cppbuilder1
Hello,
I try to create a database like this :
int p=0;int nbreenregT1=20;
TTable *Essai=new TTable(this);
Essai->Active=false;
Essai->DatabaseName=ExtractFilePath(Application->ExeName);
Essai->TableName="essai.db";
Essai->TableType=ttDefault;
Essai->FieldDefs->Clear();
do{
Essai->FieldDefs->Add(comptes,ftString,100,false);
p++ ;
}while(p!=nbreenregT1);
and at the second "do while" I obtain this message :
The number of fixed column must not be superior than the number of columns
Excuse me I try to translate it in correct English
I think I forget something???
What I'm doing wrong?
I thank you in advance
Patrick
 
 

Re:Column error

Hello Artaud,
Look for AddFieldDef in the Help file :
"Add is provided for backward compatibility. The recommended way to add new
field definitions to the Items property array is using the AddFieldDef
method." This is writen at the TFieldDefs::Add method description.
Use the Table Creation example, it works fine.
HTH
Jayme.
"Artaud" < XXXX@XXXXX.COM >escreveu na mensagem
Quote
Hello,
I try to create a database like this :
int p=0;int nbreenregT1=20;
TTable *Essai=new TTable(this);
Essai->Active=false;
Essai->DatabaseName=ExtractFilePath(Application->ExeName);
Essai->TableName="essai.db";
Essai->TableType=ttDefault;
Essai->FieldDefs->Clear();
do{
Essai->FieldDefs->Add(comptes,ftString,100,false);
p++ ;
}while(p!=nbreenregT1);
and at the second "do while" I obtain this message :
The number of fixed column must not be superior than the number of columns
Excuse me I try to translate it in correct English
I think I forget something???
What I'm doing wrong?
I thank you in advance
Patrick


 

Re:Column error

Artaud wrote:
Quote
Hello,
I try to create a database like this :
int p=0;int nbreenregT1=20;
TTable *Essai=new TTable(this);
Essai->Active=false;
Essai->DatabaseName=ExtractFilePath(Application->ExeName);
Essai->TableName="essai.db";
Essai->TableType=ttDefault;
Essai->FieldDefs->Clear();
do{
Essai->FieldDefs->Add(comptes,ftString,100,false);
p++ ;
}while(p!=nbreenregT1);
Are you assigning a new field name to 'comptes' within your do-while
loop? If not then you are creating a field with a name that already
exists. This should result in an exception.
Uwe
 

{smallsort}

Re:Column error

Thank you very much,
I have tried the example and obtain the same error message!!! I have already
used the Add method to build database, and did not have problem, I don't
understand what I'm doing wrong at this time.
I have a form on which I put a TTable component, the a Datasource I link
Datasource to the TTable and do nothing else.
And then the code in my previous message.
I have copied working code in an other part of my application too, but I
obtain the same error.
I try to understand the message "hte number of fixed columns must be less
than the numbers of column" !!
I don't understand, must forget something!!!!!
it builds the first field but not the second it stop after the AddFielDef()
in the do...while loop
this is the new code :
TableAffi->Active=false;
TableAffi->DatabaseName=Form2->chemdatabase;
TableAffi->TableName=Form2->Fichier+"ratiosaffi.db";
TableAffi->TableType=ttDefault;
//int compare;
//int num=0;
int p=0;
TableAffi->FieldDefs->Clear();
TFieldDef *pNewDef = TableAffi->FieldDefs->AddFieldDef();
do{
pNewDef = TableAffi->FieldDefs->AddFieldDef();
pNewDef->Name = "Field2";
pNewDef->DataType = ftString;
pNewDef->Size = 100;
}while(p!=nbreenregT1-1);
Thank you again very much
Excuse my English
Patrick
"Jayme Jeffman Filho" < XXXX@XXXXX.COM >a écrit dans le message de
Quote
Hello Artaud,

Look for AddFieldDef in the Help file :
"Add is provided for backward compatibility. The recommended way to add
new
field definitions to the Items property array is using the AddFieldDef
method." This is writen at the TFieldDefs::Add method description.

Use the Table Creation example, it works fine.

HTH

Jayme.


"Artaud" < XXXX@XXXXX.COM >escreveu na mensagem
news:4149c301$ XXXX@XXXXX.COM ...
>Hello,
>I try to create a database like this :
>int p=0;int nbreenregT1=20;
>TTable *Essai=new TTable(this);
>Essai->Active=false;
>Essai->DatabaseName=ExtractFilePath(Application->ExeName);
>Essai->TableName="essai.db";
>Essai->TableType=ttDefault;
>Essai->FieldDefs->Clear();
>do{
>Essai->FieldDefs->Add(comptes,ftString,100,false);
>p++ ;
>}while(p!=nbreenregT1);
>and at the second "do while" I obtain this message :
>The number of fixed column must not be superior than the number of
columns
>Excuse me I try to translate it in correct English
>I think I forget something???
>What I'm doing wrong?
>I thank you in advance
>Patrick
>
>


 

Re:Column error

Hello
I have found my error, it is very stupid!!! It was because I give the same
name for all the fields in my do while loop!!!!!!!!
I thank you very much *
Patrick
"Jayme Jeffman Filho" < XXXX@XXXXX.COM >a écrit dans le message de
Quote
Hello Artaud,

Look for AddFieldDef in the Help file :
"Add is provided for backward compatibility. The recommended way to add
new
field definitions to the Items property array is using the AddFieldDef
method." This is writen at the TFieldDefs::Add method description.

Use the Table Creation example, it works fine.

HTH

Jayme.


"Artaud" < XXXX@XXXXX.COM >escreveu na mensagem
news:4149c301$ XXXX@XXXXX.COM ...
>Hello,
>I try to create a database like this :
>int p=0;int nbreenregT1=20;
>TTable *Essai=new TTable(this);
>Essai->Active=false;
>Essai->DatabaseName=ExtractFilePath(Application->ExeName);
>Essai->TableName="essai.db";
>Essai->TableType=ttDefault;
>Essai->FieldDefs->Clear();
>do{
>Essai->FieldDefs->Add(comptes,ftString,100,false);
>p++ ;
>}while(p!=nbreenregT1);
>and at the second "do while" I obtain this message :
>The number of fixed column must not be superior than the number of
columns
>Excuse me I try to translate it in correct English
>I think I forget something???
>What I'm doing wrong?
>I thank you in advance
>Patrick
>
>


 

Re:Column error

That's I was about to tell you.
Good luck.
Jayme.