您现在的位置是:网站首页> 编程资料编程资料
深入浅析ASP在线压缩access数据库的方法_实用技巧_
2023-05-24
302人已围观
简介 深入浅析ASP在线压缩access数据库的方法_实用技巧_
ASP在线压缩ACCESS数据库原理很简单:利用JRO.JetEngine的压缩功能建立一个新的数据库文件,然后把原来的删掉、替换!既然这样,压缩程序只需几行就ok了!
把下面的代码保存为**.asp,数据库文件(db.md)放在相同目录下,执行asp搞定!
<% oldDB = server.mappath("db.mdb") '更改数据库地址 newDB = server.mappath("db_new.mdb") '生成临时文件 Set FSO = Server.CreateObject("Scripting.FileSystemObject") Set Engine = Server.CreateObject("JRO.JetEngine") prov = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" Engine.CompactDatabase prov & OldDB, prov & newDB set Engine = nothing FSO.DeleteFile oldDB '删除临时文件 FSO.MoveFile newDB, oldDB set FSO = Nothing response.write "OK" %>下面是一个ASP在线压缩ACCESS数据库的封装函数
Function CompactDB(dbPath, boolIs97) Dim fso, Engine, strDBPath strDBPath = left(dbPath,instrrev(DBPath,"\")) Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(dbPath) Then Set Engine = CreateObject("JRO.JetEngine") On Error Resume Next If boolIs97 = "True" Then Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _ & "Jet OLEDB:Engine Type=" & JET_3X Else Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb" End If If Err Then response.write "" response.end end if fso.CopyFile strDBPath & "temp.mdb",dbpath fso.DeleteFile(strDBPath & "temp.mdb") Set fso = nothing Set Engine = nothing CompactDB = "" Else CompactDB = "" End If End Function 总结
到此这篇关于ASP在线压缩access数据库的方法的文章就介绍到这了,更多相关ASP在线压缩access数据库内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
您可能感兴趣的文章:
相关内容
- ASP.net百度主动推送功能实现代码_实用技巧_
- asp .net core静态文件资源的深入讲解_实用技巧_
- .net core实用技巧——将EF Core生成的SQL语句显示在控制台中_实用技巧_
- 使用Seq搭建免费的日志服务的方法_实用技巧_
- asp.net core应用docke部署到centos7的全过程_实用技巧_
- ASP.Net中的async+await异步编程的实现_实用技巧_
- ASP.NET Core根据环境变量支持多个 appsettings.json配置文件_实用技巧_
- Linux安装.Net core 环境并运行项目的方法_实用技巧_
- 如何在ASP.Net Core中使用 IHostedService的方法_实用技巧_
- ASP.NET Core中的配置详解_实用技巧_
