利用cb在数据库中建表的问题
在帮助中有下面几行代码,其中
TFieldDef *pNewDef = Table1->AddFieldDef();报错,说Table控件中没有这个函数,请问我应该怎么改才能使这段代码运行正确呢?是不是需要家头文件?(下面是代码原文)
求各位高人指教!!!
谢谢
if (!Table1->Exists) // Don't overwrite an existing table
{
Table1->Active = false; // The Table component must not be active
// First, describe the type of table and give it a name
Table1->DatabaseName = "BCDEMOS";
Table1->TableType = ttParadox;
Table1->TableName = "CustInfo";
// Next, describe the fields in the table
Table1->FieldDefs->Clear();
TFieldDef *pNewDef = Table1->AddFieldDef();
pNewDef->Name = "Field1";
pNewDef->DataType = ftInteger;
pNewDef->Required = true;
pNewDef = Table1->AddFieldDef();
pNewDef->Name = "Field2";
pNewDef->DataType = ftString;
pNewDef->Size = 30;
// Next, describe any indexes
Table1->IndexDefs->Clear();
/* the 1st index has no name because it is a Paradox primary key */
Table1->IndexDefs->Add("","Field1", TIndexOptions() <<ixPrimary << ixUnique);
Table1->IndexDefs->Add("Fld2Index","Field2", TIndexOptions() << ixCaseInsensitive);
// Now that we have specified what we want, create the table
Table1->CreateTable();
}