|
以下是 DVBBS 7 后台用自定义函数压缩数据库代码,以供参考'====================压缩数据库 =========================
sub CompressData()If IsSqlDataBase = 1 Then
SQLUserReadme()
Exit Sub
End If
%>
<table border="0" cellspacing="1" cellpadding="5" height="1" align=center width="95%" class="tableBorder">
<form action="Admin_data.asp?action=CompressData" method="post">
<tr>
<td class="forumrow" height=25><b>注意:</b><br>输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </td>
</tr>
<tr>
<td class="forumrow">压缩数据库:<input type="text" name="dbpath" value=Data\dvbbs7.MDB>
<input type="submit" value="开始压缩"></td>
</tr>
<tr>
<td class="forumrow"><input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择
(默认为 Access 2000 数据库)<br><br></td>
</tr>
<form>
</table>
<%
dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")If dbpath <> "" Then
dbpath = server.mappath(dbpath)
response.write(CompactDB(dbpath,boolIs97))
End Ifend sub'=====================压缩参数=========================
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath,JET_3X
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = CreateObject("Scripting.FileSystemObject")If fso.FileExists(dbPath) Then
fso.CopyFile dbpath,strDBPath & "temp.mdb"
Set Engine = CreateObject("JRO.JetEngine") If boolIs97 = "True" Then
Engine.CompactDatabase "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
End Iffso.CopyFile strDBPath & "temp1.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
fso.DeleteFile(strDBPath & "temp1.mdb")
Set fso = nothing
Set Engine = nothing CompactDB = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLfElse
CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf
End IfEnd Function |
|