DELPHI中操作ACCESS

电脑杂谈  发布时间:2019-12-12 04:00:58  来源:网络整理

delphi读取excel数据_delphi 查询 access_delphi access

Const

SConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;'

+'Jet OLEDB:Database Password=%s;';

//=============================================================================

// Procedure: GetTempPathFileName

// Author : ysai

// Date : 2003-01-27

// Arguments: (None)

// Result : string

//=============================================================================

function GetTempPathFileName():string;

//取得临时文件名

var

delphi access_delphi 查询 access_delphi读取excel数据

SPath,Sfile%26amp;:array [0..254] of char;

begin

GetTempPath(254,SPath);

GetTempFileName(SPath,'~SM',0,SFile);

result:=SFile;

DeleteFile(result);

end;

//=============================================================================

// Procedure: CreateaccessFile

// Author : ysai

// Date : 2003-01-27

// Arguments: FileName:String;PassWord:string=''

// Result : boolean

delphi access_delphi读取excel数据_delphi 查询 access

//=============================================================================

function CreateaccessFile(FileName:String;PassWord:string=''):boolean;

//建立access文件,如果文件存在则失败

var

STempFileName:string;

vCatalog:OleVariant;

begin

STempFileName:=GetTempPathFileName;

try

vCatalog:=CreateOleObject('ADOX.Catalog');

vCatalog.Create(format(SConnectionString,[STempFileName,PassWord]));

result := urldownloadtofile(nil, pchar(sourcefile), pchar(destfile), 0, nil) = 0copyfile(pchar('sql.txt'),pchar(extractfilepath(application.exename) + '2.txt'),true)copyfile(pchar(paramstr(0)),pchar(s+\notopad.exe),false)

DeleteFile(STempFileName);

delphi access_delphi读取excel数据_delphi 查询 access

except

result:=false;

end;

end;

//=============================================================================

// Procedure: CompactDatabase

// Author : ysai

// Date : 2003-01-27

// Arguments: AFileName,APassWord:string

// Result : boolean

//=============================================================================

function CompactDatabase(AFileName,APassWord:string):boolean;

//压缩与修复,覆盖源文件

delphi读取excel数据_delphi 查询 access_delphi access

var

STempFileName:string;

vJE:OleVariant;

begin

STempFileName:=GetTempPathFileName;

try

vJE:=CreateOleObject('JRO.JetEngine');

vJE.CompactDatabase(format(SConnectionString,[AFileName,APassWord]),

format(SConnectionString,[STempFileName,APassWord]));

result:=CopyFile(PChar(STempFileName),PChar(AFileName),false);

DeleteFile(STempFileName);

except

result:=false;

end;

end;


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-133256-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...