为什么我用论坛经典的用ADO压缩Access2000库的方法无法成功了,(没有分了,补满50分,我就结贴)谢谢各路打下了
icwin 2004-12-24 11:12:24 我用您的方法单是始终不能成功,非常感谢了
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleSysError with message '不正确的变量类型。'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
===
// 用ADO压缩Access2000库
#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);
}
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");
}