日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

压缩access数据库

發布時間:2023/12/18 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 压缩access数据库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

遇到一個問題,使用的是accesss數據庫,在加載數據庫中的信息的時候,速度特別慢,有時候一次查詢最終會卡15秒左右,然后才能得到結果,跟蹤發現卡的地方在SQLExecDirect中,已經是odbc api了。打開數據庫看也沒發現啥問題,后來點了access上邊的 “壓縮和修復數據庫”工具,數據庫從原來的 8M 瞬間變成了 800k ,使用壓縮后的數據庫時速度就特別快了,不知道是不是access數據庫的啥毛病,記錄下壓縮用到的代碼:
關鍵代碼:

CDaoWorkspace dao;//將 Properties.mdb 壓縮為 Properties_comp.mdbdao.CompactDatabase(g_CurrentPath + "Properties.mdb",g_CurrentPath + "Properties_comp.mdb");

壓縮之后替換原來的文件,完整代碼:

VOID CLoginPasswordDlg::CompactDatabase() {try{CFileFind finder;if(finder.FindFile(g_CurrentPath + "Properties_comp.mdb")){finder.Close();DeleteFile(g_CurrentPath + "Properties_comp.mdb");}if(finder.FindFile(g_CurrentPath + "Properties.mdb")){finder.Close();CFile file;if(file.Open(g_CurrentPath + "Properties.mdb",CFile::modeReadWrite)){file.Close();CDaoWorkspace dao;dao.CompactDatabase(g_CurrentPath + "Properties.mdb",g_CurrentPath + "Properties_comp.mdb");}}}catch(...){OutputDebugString("CompactDatabase exception.");}try{CFileFind finder;if(finder.FindFile(g_CurrentPath + "Properties.mdb") && finder.FindFile(g_CurrentPath + "Properties_comp.mdb")){finder.Close();if(!CopyFileA(g_CurrentPath + "Properties_comp.mdb",g_CurrentPath + "Properties.mdb",FALSE))OutputDebugString("CopyFile failed.");DeleteFile(g_CurrentPath + "Properties_comp.mdb");}}catch(...){} }

需要包含頭文件:

#include "afxdao.h"

總結

以上是生活随笔為你收集整理的压缩access数据库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。