Anywhere you go, let me go too

關於部落格
對人海闊天空,做事仔細周密
----------------------
因為改了平台後...覺得不是很好用....所以有另外......(評估中)
http://blog.xuite.net/king119wang/myskills
  • 32543

    累積人氣

  • 2

    今日人氣

    0

    訂閱人氣

C# 進行ACCESS資料壓縮

還是要看method文件,不然無法確切帶入應帶的參數值
我的程式碼如下
db.CompactDatabase(sSrcPath, compact_file, null, null, password);
出現
找不到可安裝的isam access2000 compact
後來改寫成
db.CompactDatabase(sSrcPath, compact_file, null, null, ";pwd="+sDBpass);
就成功了
 
  /// <summary>
        /// 進行MS ACCESS DB COMPACT
        /// </summary>
        /// <param name="sSrcPath">來源mdb位置</param>
        /// <param name="sDBpass">db密碼</param>
        /// <returns></returns>
        public int doMSAccessCompact(string sSrcPath,string sDBpass) {
              int iResult=-1;     
            string compact_file = string.Empty;
            string back_file = string.Empty;
            try {
 
 
                if (File.Exists(sSrcPath))
                {
                    back_file = sSrcPath.Replace(Path.GetFileName(sSrcPath), Path.GetFileNameWithoutExtension(sSrcPath) + "_back" + Path.GetExtension(sSrcPath));
                    compact_file = sSrcPath.Replace(Path.GetFileName(sSrcPath), Path.GetFileNameWithoutExtension(sSrcPath) + "_tmp" + Path.GetExtension(sSrcPath));
                    DBEngineClass db = new DBEngineClass();
                    db.CompactDatabase(sSrcPath, compact_file, null, null, ";pwd="+sDBpass);
                    if (File.Exists(compact_file))
                    {
                        File.Delete(sSrcPath);
                        File.Move(compact_file, sSrcPath);
                        File.Copy(sSrcPath, back_file);
                    }
 
                }
 
                iResult = 0;
 
            }catch(Exception ex){
                sErrMsg = ex.Message;
                iResult = -3;
            }
            return iResu


method參考位置
http://social.msdn.microsoft.com/Search/en-US/Office?query=dbengine.compactdatabase&Refinement=68&ac=3
 
http://social.msdn.microsoft.com/Forums/office/en-US/b6b7280a-8e60-459a-9ec7-b3aa4ada828f/compact-database-with-password-in-visual-studio
ADO DAO版本
http://www.redcirclesoftware.com/deep-dive-dao-and-ado-field-type-mapping/


 
相簿設定
標籤設定
相簿狀態