请问各位高手:
如何通过asp来压缩数据库呢?还有清空数据库,还原数据库呢?它的原理是怎样的呀?请指点一下,谢谢了.
參考答案:ASP 压缩数据库的例子
DIm Objfso
Objfso = "Scripting.FileSystemObject"
Dim Db
Db="dvbbs7.asp" '这里请根据你实际数据库名称替换
Call Compact
Sub Compact
Response.Write CompactDB(Server.Mappath(db),false)
End Sub
'=====================压缩数据库=========================
Function CompactDB(dbPath, boolIs97)
On Error Resume Next
Dim fso, Engine, strDBPath,JET_3X
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = CreateObject(Objfso)
If Err Then
Err.Clear
CompactDB = Lang.item("g_110") & vbCrLf
Exit Function
End If
If fso.FileExists(dbPath) Then
fso.CopyFile dbpath,strDBPath & "temp.mdb"
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
End If
fso.CopyFile strDBPath & "temp1.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
fso.DeleteFile(strDBPath & "temp1.mdb")
Set fso = Nothing
Set Engine = Nothing
Response.Write "压缩成功!"
Else
Response.Write "没搞定,再来一次?"
End If
End Function
%>