码迷,mamicode.com
首页 > 其他好文 > 详细

临时代码

时间:2015-02-10 14:42:50      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

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:\temp.mdb);

  FCatalog := CoCatalog.Create;
  FCatalog.Create(GetAdoAccConStr(s:\temp.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:\temp.mdb);

  tmpQuery := TAdoQuery.Create(nil);
  try
    tmpQuery.ConnectionString :=
      Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:\temp.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:\temp.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:\temp.mdb);
  access := CreateOleObject(ADOX.Catalog);
  access.Create(Provider=Microsoft.Jet.OLEDB.4.0;Data Source=s:\temp.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;

 

临时代码

标签:

原文地址:http://www.cnblogs.com/CodeGear/p/4283593.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!