Home  >  Article  >  Database  >  用ADO压缩Access2000库

用ADO压缩Access2000库

WBOY
WBOYOriginal
2016-06-07 15:50:031341browse

欢迎进入C/C++编程社区论坛,与200万技术人员互动交流 >>进入 #include "utilcls.h" void CompactDatabase(String f1,String psw1, String f2,String psw2) { String Provider1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + f1 + ";Jet OLEDB:Databas

欢迎进入C/C++编程社区论坛,与200万技术人员互动交流 >>进入

      #include  "utilcls.h"

    void  CompactDatabase(String  f1,String  psw1,  String  f2,String  psw2)
    {
           String  Provider1="Provider=Microsoft.Jet.OLEDB.4.0;Data  Source="
                   +  f1  +  ";Jet  OLEDB:Database  PassWord="  +  psw1;
           String  Provider2="Provider=Microsoft.Jet.OLEDB.4.0;Data  Source="
                   +  f2  +  ";Jet  OLEDB:Database  Password="  +  psw2;

           Variant  Adoobj=Variant::CreateObject("JRO.JetEngine");
           Adoobj.OleProcedure("CompactDatabase",Provider1,Provider2);
           AdoObj.Clear(  );      //  释放  ADO对象
    }

    void  __fastcall  TForm1::Button1Click(TObject  *Sender)
    {
             String  f1="yhecdagl1.mdb";          //  源库1
    String  psw1="yhecdagl";                //  密码1

             String  f2="yhecdagl2.mdb";          //  新目的库2
             String  psw2="yhecdagl2";              //  新密码2

             String  dir=ExtractFilePath(Application->ExeName);
             if  (FileExists(f2))
                     DeleteFile(f2);
             CompactDatabase(dir+f1,psw1,dir+f2,psw2);
             ShowMessage("Finished");
    }

用ADO压缩Access2000库

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn