Public Cn As ADODB.Connection
Set Cn = New ADODB.Connection
strcon = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=jtsg;Data Source=" + ServerIp + ";" + _
"use procedure for prepare=1;auto translate=true;" + _
"use encryption for data=false;tag with column collation when possible=false"
Cn.ConnectionString = strcon
On Error Resume Next
Cn.Open
If Cn.Errors.Count > 0 Then
For i = 0 To Cn.Errors.Count - 1
If Cn.Errors(i).Number = -2147467259 Then
MsgBox "网络不通或服务器未开,请确认后再试", vbOKOnly + vbInformation, "提醒"
Unload Me
Exit Sub
Exit For
End If
Next i
End If
Private Sub BackupAll()
Cn.Execute "backup database jtsg to disk='" + App.Path + "/backup/myjtsgall.bak' with name='jtsg backup all',description='Full Backup Of jtsg'"
MsgBox "数据完全备份已经完成", vbOKOnly + vbInformation, "提醒"
End Sub
Private Sub BackupDif()
Cn.Execute "backup database jtsg to disk='" + App.Path + "/backup/myjtsgdif.bak' with differential ,noinit,name='jtsg backup dif',description='Differential Backup Of jtsg'"
MsgBox "数据差异备份已经完成", vbOKOnly + vbInformation, "提醒"
End Sub
Private Sub RestoreData()
Cn.Execute "restore database jtsg from disk='" + App.Path + "/backup/myjtsgall.bak' with FILE=1"
MsgBox "数据恢复已经完成", vbOKOnly + vbInformation, "提醒"
End Sub