• 临时代码


    var
      access, t: OleVariant;
      tmpQuery: TADOQuery;
      FTable: _Table;
      FCatalog: _Catalog;
      FIndex: _Index;
      I: Integer;
      pty: adox_tlb.Property_;
      pties: adox_tlb.Properties;
      vrs: _Recordset;
    begin
      DeleteFile('s:	emp.mdb');
    
      FCatalog := CoCatalog.Create;
      FCatalog.Create(GetAdoAccConStr('s:	emp.mdb'));
    
      FTable := CoTable.Create;
      FTable.ParentCatalog := FCatalog;
      FTable.Name := 'test';
    
      FTable.Columns.Append('ISBN', adVarWChar, 50);
      FTable.Columns.Append('Price', adInteger, 4);
      FTable.Columns.Append('date', adDate, 0);
    //  FCatalog.Tables['test'].Columns['ISBN'].Properties['']
      FTable.Columns['ISBN'].Properties['Jet OLEDB:Allow Zero Length'].Value := False;
    
      FIndex := CoIndex.Create;
      with FIndex do
      begin
        Name := 'ISBN';
        PrimaryKey := True;
        Unique := True;
        Columns.Append('ISBN', adVarWChar, 50);
      end;
    
      FTable.Indexes.Append(FIndex, EmptyParam);
      FCatalog.Tables.Append(FTable);
    
      pties := FTable.Columns['date'].Properties;
    
      for I := 0 to pties.Count - 1 do
      begin
        pty := pties.Item[I];
        Memo1.Lines.Add(  pty.Name + '-' + VarToStr(pty.Value));
      end;
      Exit;
      access := CreateOleObject('ADOX.Catalog');
      access.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:	emp.mdb');
    
      tmpQuery := TAdoQuery.Create(nil);
      try
        tmpQuery.ConnectionString :=
          'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:	emp.mdb;Persist Security Info=True';
        with tmpQuery do
        begin
          Close;
          Sql.Clear;
          Sql.Add('CREATE TABLE T_test ');
          Sql.Add('( ');
          Sql.Add('t_a1 varchar(10), ');
          Sql.Add('t_a2 varchar(20) ');
          Sql.Add(')');
          ExecSql;
        end;
          //其实这里有 值的  ,和下面一样
        //下面一句 必须
        access.activeconnection :=
          'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:	emp.mdb;Persist Security Info=True';
    
        access.Tables['T_Test'].Columns['t_a1'].Properties('Jet OLEDB:Allow Zero Length') := true;
        access := Null;
    
        MessageBox(HANDLE, '成功创建。', '提示', MB_OK or
          MB_ICONINFORMATION);
      finally
        tmpQuery.Free;
      end;
    end;
    procedure TFormLOrder.Button3Click(Sender: TObject);
    var access, tbl:OleVariant;
      tmpQuery:TADOQuery;
    begin
      DeleteFile('s:	emp.mdb');
      access := CreateOleObject('ADOX.Catalog');
      access.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:	emp.mdb');
      try
    
        tbl := createOleobject('ADOX.Table');
        tbl.Name := 'T_Test';
        tbl.Columns.Append('t_a1');
        tbl.Columns.Append('t_a2');
        access.Tables.append(tbl);
    
        access.Tables['T_Test'].Columns['t_a1'].Properties('Jet OLEDB:Allow Zero Length'):=true;
        access := Null;
    
        MessageBox(HANDLE,'成功创建。','提示',MB_OK or MB_ICONINFORMATION);
      finally
        tmpQuery.Free;
      end;
    end;
  • 相关阅读:
    【题解】1621. 未命名
    【模板】关于vector的lower_bound和upper_bound以及vector基本用法 STL
    【题解】数颜色 STL vector数组
    【题解】斐波拉契 luogu3938
    【题解】天天酷跑
    【题解】Grape luogu1156改 dp
    【题解】逐个击破 luogu2700
    【题解】ball 数论
    【题解】逐个击破 luogu2700
    【题解】平方根
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4283593.html
Copyright © 2020-2023  润新知