紧凑型数据库访问2000 [英] compact DB access 2000
本文介绍了紧凑型数据库访问2000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好吗,可以告诉我如何在我的网页(互联网)中压缩DB Access2000.
电子邮件:chuchufuentes@hotmail.com
谢谢:sigh:
Hi, how are you, could tell me how can i compact DB Access 2000 in my webpage (internet).
Email:chuchufuentes@hotmail.com
Thank you :sigh:
推荐答案
我是在一些旧代码中找到的,但是不要以为我曾经尝试过,也不知道它来自哪里,但是您可以试一试.
I found this in some old code, but don''t think I ever tried it and have no idea where it came from, but you might give it shot.
/// <summary>
/// !!IMPORTANT!!
/// !make sure there's no open connections to your db before calling this method!
/// !!IMPORTANT!!
/// </summary>
/// <param name="connectionString">connection string to your db</param>
/// <param name="mdwfilename">FULL name of an MDB file you want to compress.</param>
public static void CompactAccessDB(string connectionString, string mdwfilename)
{
object[] oParams;
//create an inctance of a Jet Replication Object
object objJRO = Activator.CreateInstance(Type.GetTypeFromProgID("JRO.JetEngine"));
//filling Parameters array
//change "Jet OLEDB:Engine Type=5" to an appropriate value
// or leave it as is if you db is JET4X format (access 2000,2002)
//(yes, jetengine5 is for JET4X, no misprint here)
oParams = new object[] { connectionString, "Provider=Microsoft.Jet.OLEDB.4.0;Data" +
" Source=C:\\tempdb.mdb;Jet OLEDB:Engine Type=5"};
//invoke a CompactDatabase method of a JRO object
//pass Parameters array
objJRO.GetType().InvokeMember("CompactDatabase",
System.Reflection.BindingFlags.InvokeMethod,
null,
objJRO,
oParams);
//database is compacted now
//to a new file C:\\tempdb.mdb
//let's copy it over an old one and delete it
System.IO.File.Delete(mdwfilename);
System.IO.File.Move("C:\\tempdb.mdb", mdwfilename);
//clean up (just in case)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objJRO);
objJRO = null;
}
也许那会给您一些关于Google的想法.
Maybe that''ll give you some ideas of what to google anyway.
这篇关于紧凑型数据库访问2000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文