如下:procedure TForm1.Button1Click(Sender: TObject);
VARtable:ttable;begin
table:=TTABLE.create(self);
table.databasename:='';
table.tabletype:=ttparadox;
table.tablename:='';
table.FieldDefs.Add('ASF',FTSTRING);
table.IndexDefs.Add('A','ASF',[ixPrimary]);
table.CreateTable;
end;载有,我想在C盘下建这个表,该如何写?

解决方案 »

  1.   

    用queryqurey.databasename:=ExtractFilePath(Application.ExeName);  //('c:\')
    Query.sql.clear;
    query.sql.add('create table myTable (');
    //开始添加字段
    query.sql.add(...)
    ...
    Query.sql.add(' )')
    //添加字段完成
    Query.ExeSQL;  // 是这样表示吗?我在网吧啦
      

  2.   

    table.databasename:='c:\';
    table.tablename:='mytable';
      

  3.   

    table:=TTable.Create(Self);with table do
     begin
      DatabaseName:='DBDEMOS';
      TableName:='aa';
      TableType:=ttParadox;
      with FieldDefs do
        begin
          Clear;
          Add('a',ftInteger,0,false);
           Add('b',ftBoolean,0,false);
          Add('c',ftString,10,false);
        end;
      with IndexDefs do
        begin
          Clear;
          Add(’Primary’,'a',[ixPrimary,ixUnique]);
        end;
      CreateTable; 
      end;
    这样应该就可以的
      

  4.   

    帮助关键字:CreateTable,example (Delphi)with Table1 do begin
      Active := False;  
      DatabaseName := 'DBDEMOS';
      TableType := ttParadox;
      TableName := 'CustInfo';  { Don't overwrite an existing table }  if not Table1.Exists then begin
        { The Table component must not be active }
        { First, describe the type of table and give }
        { it a name }
        { Next, describe the fields in the table }
        with FieldDefs do begin
          Clear;
          with AddFieldDef do begin
            Name := 'Field1';
            DataType := ftInteger;
            Required := True;
          end;
          with AddFieldDef do begin        Name := 'Field2';
            DataType := ftString;
            Size := 30;
          end;
        end;
        { Next, describe any indexes }
        with IndexDefs do begin
          Clear;
          { The 1st index has no name because it is
          { a Paradox primary key }
          with AddIndexDef do begin
            Name := '';
            Fields := 'Field1';
            Options := [ixPrimary];
          end;
          with AddIndexDef do begin        Name := 'Fld2Indx';
            Fields := 'Field2';
            Options := [ixCaseInsensitive];
          end;
        end;
        { Call the CreateTable method to create the table }
        CreateTable;
      end;
    end;
      

  5.   

    procedure TForm1.ToolButton17Click(Sender: TObject);
    var Table1:TTable;
    begin
      Table1 := TTable.Create(self);
      with Table1 do begin
        Active := False;
        DatabaseName := 'C:\';
        TableType := ttParadox;
        TableName := 'CustInfo';
        { Don't overwrite an existing table }
        if not Table1.Exists then begin
          { The Table component must not be active }
          { First, describe the type of table and give }
          { it a name }
          { Next, describe the fields in the table }
          with FieldDefs do begin
            Clear;
            with AddFieldDef do begin
              Name := 'Field1';
              DataType := ftInteger;
              Required := True;
            end;
            with AddFieldDef do begin          Name := 'Field2';
              DataType := ftString;
              Size := 30;
            end;
          end;
          { Next, describe any indexes }
          with IndexDefs do begin
            Clear;
            { The 1st index has no name because it is
            { a Paradox primary key }
            with AddIndexDef do begin
              Name := '';
              Fields := 'Field1';
              Options := [ixPrimary];
            end;
            with AddIndexDef do begin          Name := 'Fld2Indx';
              Fields := 'Field2';
              Options := [ixCaseInsensitive];
            end;
          end;
          { Call the CreateTable method to create the table }
          CreateTable;
        end;
      end;
    end;我试过了,好用的。上面的是帮助里的。