Hola Yugo.
Revisa este ejemplo:
Código:
/* Crear tabla */
void TablaCreate(String tableName) {
TTable *tb = new TTable(NULL);
tb->Close();
tb->DatabaseName = ExtractFilePath(Application->ExeName); // ruta
tb->TableName = tableName;
tb->TableType = ttParadox;
tb->FieldDefs->Clear();
tb->FieldDefs->Add("ID", ftAutoInc, 0, false);
tb->FieldDefs->Add("NOMBRE", ftString, 30, false);
tb->FieldDefs->Add("DOMICILIO", ftString, 30, false);
tb->FieldDefs->Add("TELEFONO", ftString, 15, false);
tb->IndexDefs->Clear();
tb->IndexDefs->Add("", "ID", TIndexOptions()<< ixPrimary << ixUnique);
tb->IndexDefs->Add("INDNOMBRE", "NOMBRE", TIndexOptions()<< ixCaseInsensitive);
tb->CreateTable();
delete tb;
}
/* Verificar nombre */
bool isValidName(String str) {
if (str == "" || (str[1]>='0'&&str[1]<='9'))
return false;
for(int i=1; i< str.Length(); i++) {
char c = UpCase(str[i]);
if(!((c>='A'&&c<='Z') || (c>='0'&&c<='9') || (c=='_')))
return false;
}
return true;
}
/* Ejemplo de uso */
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String name;
bool ok;
do {
if(InputQuery("Crear tabla", "Nombre", name))
ok = isValidName(name);
} while ((name != "") && !ok);
if (name != "")
TablaCreate(name);
}
Saludos