对了,我用的数据库是sql2000,,我想用delphi做个模块来实现表的创建,而不是用数据库,来建。

解决方案 »

  1.   

    var
    table :Ttable;
    .....
    begin
    table:=ttable.creat(self);
    table.databasename:='mydatabase';
    table.tablename:='mytable.db';
    datasource:=Tdatasource.create(self);
    .....
    table.fieldefs.add('id号',FTSTRING,30,FALSE);
    ......
      

  2.   

    to s-x-d
    sorry 我是个delphi新手,能不能将代码给我啊,
      

  3.   

    用TADOCOMMAND,把TSQL脚本语句作为CMDTEXT的参数,然后执行即可
      

  4.   

    留个email 吧!
      邮你一份
      

  5.   

    给你个例子,下面是一个用ADOQUERY创建一个数据表。
    With dbcreatadoquery do //dbcreatadoquery  is adoquery
      begin
      Close;
      SQL.Clear;
      createsql:='create table databasecheck '+
      '(ID INT IDENTITY(1,1) NOT NULL ,'+
      'TABLENAMEID INT  NULL ,'+
      'TABLENAME CHAR(50) NOT NULL,'+
      'FIELDNAME CHAR(50) NOT NULL,'+
      'XTYPE INT NOT NULL,'+
      'LENGTH INT NOT NULL,'+
      'CDEFAULT INT  NULL,'+
      'DEFAULTSTR CHAR(20) NULL,'+
      'ISNULLABLE INT NULL,'+
      'KEYSTR INT NULL,'+
      'INDEXNAME CHAR(50) NULL);';
       SQL.Add(createsql);
       ExecSQL;
    end;
      

  6.   

    用SQL的语句Create Table就可以了。
      

  7.   

    The following example shows how to create a table.{ Don't overwrite an existing table }if not Table1.Exists then begin
      with Table1 do begin
        { The Table component must not be active }
        Active := False;  
        { First, describe the type of table and give }
        { it a name }
        DatabaseName := 'DBDEMOS';
        TableType := ttParadox;
        TableName := 'CustInfo';
        { 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;