asp在线压缩access数据库(源码)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <% dim action,db db="你的数据库的路径" action=Trim(request("action")) Select Case action Case "CompressData" '压缩数据 Call CompressData() end Select %><span id="more-374"></span> <html> <head> <title>Acc数据库压缩</title> </head> <body bgcolor="#c4d8ed"> <table border="0" cellspacing="1" cellpadding="5" height="1" align="center" width="100%" class="adminTableBorder"> <tr> <td class="adminTableTitle" height="25" align="center" valign="middle"><b>压缩数据库</b></td> </tr> <form action="admin_data.asp?action=CompressData" method="post" name="CompressDataForm"> <tr> <td class="adminTd" height=25><b>注意:</b><br>输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </td> </tr> <tr> <td class="adminTd">压缩数据库:<input type="text" name="dbpath" value="<%=db%>"> <input type="submit" class="button" value="开始压缩"></td> </tr> <tr> <td class="adminTd"><input type="checkbox" class="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择(默认为 Access 2000 数据库)<br><br></td> </tr> </form> </table> </body></html> <% sub CompressData() dim dbpath,boolIs97 dbpath = request("dbpath") boolIs97 = request("boolIs97") If dbpath <> "" Then dbpath = server.mappath(dbpath) response.write(CompactDB(dbpath,boolIs97)) End If end sub '=====================压缩参数========================= Function CompactDB(dbPath, boolIs97) Dim fso, Engine, strDBPath,JET_3X dbPath = Replace(dbPath,chr(0),"") 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 "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 CompactDB = "<span style='font-size:14px;color:#135294;'>你的数据库: " & dbpath & ", 已经压缩成功!</span>" & vbCrLf Else CompactDB = "<span style='font-size:14px;color:#135294;'>数据库名称或路径不正确. 请重试!</span>" & vbCrLf End If End Function %> |
上一篇: asp中javascript连接access数据库
下一篇: 淘宝网上的差评 [搞笑]
目前这篇文章有1条评论(Rss)