procedure TDMpara.CreateDescTable(chartype: string; isFillInData: boolean =
False);
begin
with tblLocalDESC do
begin
Active := false;
TableName := chartype + 'DESC'; {表格名}
TableType := ttParadox; {数据库类型}
with FieldDefs do
begin {增加字段}
Clear;
Add('Title', ftString, 30, true); {监控名 String(30)}
Add('Chars', ftstring, 200, False); {监控描述 String(30)}
end;
{ with IndexDefs do begin //增加索引
Clear; //按书号字段建立主索引
Add('SHSY','SH',[ixPrimary,ixUnique]);
end;
}
CreateTable;
end;
if isFillInData then
FillInDescTableData();
end;
procedure CreateDb(DbName: string;strSql:Tstrings);
var
Dbnew:OleVariant;
adoqTmp:TADOQuery;
intCyc:integer;
begin
if FileExists(DbName) then
begin
MessageBox(Application.Handle,PChar('数据库:' + DbName+'已经存在!'),
CommonTitle,CommonFlag);
exit;
end;
//建库
dbnew:=CreateOleObject('ADOX.Catalog');
dbnew.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + DbName);
//建表
adoqTmp:=TADOQuery.Create(nil);
adoqTmp.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='
+dbname+';Persist Security Info=False';
for intCyc:=0 to strsql.Count-1 do
begin
with adoqTmp do
begin
Close;
SQL.Text:=strSql[intcyc];
ExecSQL;
end;
end;
MessageBox(Application.Handle,PChar('数据库:' + DbName+'创建完成'),
CommonTitle,CommonFlag);
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
CreateAccess:OleVariant;
begin
CreateAccess:=CreateOleObject('ADOX.Catalog');
CreateAccess.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:/temp/Aceco.mdb;Jet OLEDBatabase Password=55629');