怎样用TTable创建带关键字的数据库?

解决方案 »

  1.   

    粘贴自[delphi 帮助]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();
    }
      

  2.   

    在创建表的时候,界面的右边有一下拉的列表框,里面有second indexs,就可以啦