久久―日本道色综合久久,亚洲欧美精品在线,狼狼色丁香久久婷婷综合五月,香蕉人人超,日本网站黄,国产在线观看不卡免费高清,无遮挡的毛片免费

2023信創(chuàng)獨角獸企業(yè)100強
全世界各行各業(yè)聯(lián)合起來,internet一定要實現(xiàn)!

DELPHI中操作ACCESS數(shù)據(jù)庫

2004-02-11 eNet&Ciweek

  DELPHI中操作ACCESS數(shù)據(jù)庫(建立.mdb文件,壓縮數(shù)據(jù)庫)

  以下代碼在WIN2K,D6,MDAC2.6下測試通過,

  編譯好的程序在WIN98第二版無ACCESS環(huán)境下運行成功.

  //聲明連接字符串

  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

  SPath,Sfile&: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

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

  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:=CopyFile(PChar(STempFileName),PChar(FileName),True);

   DeleteFile(STempFileName);

  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;

  //壓縮與修復(fù)數(shù)據(jù)庫,覆蓋源文件

  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;

  

相關(guān)頻道: eNews

您對本文或本站有任何意見,請在下方提交,謝謝!

投稿信箱:tougao@enet16.com