命令是什么,如能用代码写出来,不胜感激。
解决方案 »
- ADO对象与DATAGRID绑定问题
- 我要VB所以有转义符!好心人好发出来行吗?
- 怎么样做出的安装程序在Win98.win2000.winXP下都能运行?
- 如何控制Windows Services的启动和停止?
- 急!急!请问在用VB编程时如果VB控件能实现的,同时API也能实现的,从系统角度和程序运行角度来说用什么方法好?
- 一个与VB无关的问题!大家看看,给个意见,帮帮我
- mshflexgrid做录入怎样进行传递呢?
- 如何用VB编一个禁止QQ发送特定消息的程序?
- vb中有没有像delphi中的notebook这种控件?
- 怎么从当前窗体中读出另一个窗体中Text控件中的内容
- 在备份SQL2000数据库时如何显示进度条?
- 如何用VBE打开vb6.0工程中的.bas文件?
'''*On Error Resume Next
Dim oldMdb As String
Dim newMdb As String cnnCMMS.Close oldMdb = App.Path & "\msDATA.mdb"
newMdb = App.Path & "\msDATAcopy.mdb" DBEngine.CompactDatabase oldMdb, newMdb, , , ";" Kill oldMdb Name newMdb As oldMdb Dim sConnect As String
Dim sSource As String
sSource = "Data Source=" & App.Path & "\msDATA.mdb"
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & sSource
Set cnnCMMS = New ADODB.Connection
With cnnCMMS
.CursorLocation = adUseClient '.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open sConnect
End With
MsgBox "压缩已完成!"
End Sub
''''*On Error Resume Next
Dim oldMdb As String
Dim newMdb As String
Dim SHFileOp As SHFILEOPSTRUCT SHFileOp.wFunc = FO_COPY
SHFileOp.pFrom = App.Path & "\back\msDATAformobile.mdb"
SHFileOp.pTo = App.Path & "\msDATAformobile.mdb"
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR
Call SHFileOperation(SHFileOp) MsgBox "复原已完成!" Exit Sub
End Sub
Public Function CompDatabase() As Boolean
On Error GoTo ErrMsg
Dim JRO As New JRO.JetEngine
Dim tempDBPath As String
Dim conStr1 As String, conStr2 As String
Dim i As Integer
If MsgBox("你确定要压缩当前数据库吗?", vbQuestion + vbOKCancel + vbDefaultButton2, "小心!") = vbCancel Then
Exit Function
End If
Screen.MousePointer = 11
For i = Len(MdbSourcePath) To 1 Step -1
If Mid(MdbSourcePath, i, 1) = "\" Then
tempDBPath = Left(MdbSourcePath, i) & "tempDocument.mdb"
Exit For
End If
Next i
If Dir(tempDBPath) <> "" Then
Kill tempDBPath
End If
conStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbSourcePath & ";jet oledb:database password=790319"
conStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tempDBPath & ";jet oledb:database password=790319"
con.Close '先关闭全局连接
JRO.CompactDatabase conStr1, conStr2
Kill MdbSourcePath
Name tempDBPath As MdbSourcePath
ConnectDatabase con '再开启全局连接
Screen.MousePointer = 0
MsgBox "数据库压缩成功", vbInformation + vbOKOnly, "祝贺"
CompDatabase = True
Exit Function
ErrMsg:
Screen.MousePointer = 0
CompDatabase = False
MsgBox "请确保其它应用程序没有使用当前数据库!" & vbCrLf & Err.Description & "然后关闭其它所有子窗体后再恢复!", vbInformation + vbOKOnly, "提示"
CheckConnection con
End Function
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
'Public Const FO_COPY = &H3
'Public Const FOF_ALLOWUNDO = &H40Public Const FO_MOVE = &H1
Public Const FO_COPY = &H2
Public Const FO_DELETE = &H3
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_NOCONFIRMMKDIR = &H200
Public Const FOF_ALLOWUNDO = &H40
Public Const FOF_SILENT = &H4
Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
''''*On Error Resume Next
Dim oldMdb As String
Dim newMdb As String
Dim SHFileOp As SHFILEOPSTRUCT SHFileOp.wFunc = FO_COPY
SHFileOp.pFrom = App.Path & "\back\msDATA.mdb"
SHFileOp.pTo = App.Path & "\msDATAf.mdb"
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR
Call SHFileOperation(SHFileOp) MsgBox "复原已完成!" Exit Sub
End Sub