PARADOX 数据库: with Table1 do begin Active := False; DatabaseName := 'DBDEMOS'; TableType := ttParadox; TableName := 'CustInfo'; { Don't overwrite an existing table } if not Table1.Exists then begin { The Table component must not be active } { First, describe the type of table and give } { it a name } { 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;
with Table1 do begin
Active := False;
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo'; { Don't overwrite an existing table } if not Table1.Exists then begin
{ The Table component must not be active }
{ First, describe the type of table and give }
{ it a name }
{ 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;
你用SQLCONNECTION 和SQL Query写为什么不行呢,贴出来看看
go
.....
go
但总是提示语法错误!
SConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;'
+ 'Jet OLEDB:Database Password=%s;';function GetTempPathFileName(): string;
var
SPath, SFile: array[0..254] of char;
begin
GetTempPath(254, SPath);
GetTempFileName(SPath, '~SM', 0, SFile);
result := SFile;
DeleteFile(result);
end;//这里是关键
function CreateAccessFile(FileName: string; PassWord: string = ''): boolean;
var
STempFileName: string;
vCatalog: OleVariant;
begin
STempFileName := GetTempPathFileName;
try
vCatalog := CreateOleObject('ADOX.Catalog');
vCatalog.Create(format(SConnectionString, [STempFileName, PassWord]));
result := CopyFile(PChar(STempFileName), PChar(FileName), True);
DeleteFile(STempFileName);
except
result := false;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
CreateAccessFile('C:\aa.mdb');
end;