zoukankan      html  css  js  c++  java
  • 临时代码

    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;
  • 相关阅读:
    Best Time to Buy and Sell Stock III
    Valid Palindrome
    Longest Substring Without Repeating Characters
    Copy List with Random Pointer
    Add Two Numbers
    Recover Binary Search Tree
    Anagrams
    ZigZag Conversion
    Merge k Sorted Lists
    Distinct Subsequences
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4283593.html
Copyright © 2011-2022 走看看