Home > Database > Mysql Tutorial > 压缩修复Access数据库

压缩修复Access数据库

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:28:16
Original
1150 people have browsed it

using JRO //引用 public void Compact(string mdbPath) { if (!File.Exists(mdbPath)) { throw new Exception(目标数据库不存在,无法压缩!); } //临时数据库名称 string temp = DateTime.Now.ToString(yyyyMMddHHmmss) .bak; //临时数据库地址(包含名称

using JRO //引用

public void Compact(string mdbPath)

{
if (!File.Exists(mdbPath))
{
throw new Exception("目标数据库不存在,无法压缩!");

}

//临时数据库名称

string temp = DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";

//临时数据库地址(包含名称)

temp = mdbPath.Substring(0, mdbPath.LastIndexOf("\\")+1) + temp;

//临时数据库连接字符串

string temp2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+temp;

//原始数据库连接字符串

string mdbPath2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath;
//压缩Access数据库工具类(.dll c:\C:\Program Files (x86)\Common Files\System\ado\msjro.dll)
JetEngineClass jt = new JetEngineClass();
jt.CompactDatabase(mdbPath2,temp2);
File.Copy(temp,mdbPath,true);
File.Delete(temp);
}
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template