티스토리 뷰

컴퓨터 이야기/VC++/MFC

C# MSDN 최적화 하기

그린베어 2011. 10. 15. 22:11

//[COM]Microsoft OLE DB Provider for Jet and Replication Objects
JRO.JetEngine Jro = new JRO.JetEngineClass();
string CnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
string SourceDbPath = "c:\\Northwind.mdb";
string TmpDbPath = System.IO.Path.GetTempFileName();

System.IO.File.Delete(TmpDbPath);

try
{
Jro.CompactDatabase(CnString + "Data Source=" + SourceDbPath, CnString + "Data Source=" + TmpDbPath);
System.IO.File.Copy(TmpDbPath, SourceDbPath, true);
MessageBox.Show("ok!!");
}
catch(Exception ex)
{
if(System.IO.File.Exists(TmpDbPath))
{
System.IO.File.Delete(TmpDbPath);
}
MessageBox.Show(ex.Message);
}

반응형
댓글