你的程序肯定不能正常运行,因为SQL Server不能恢复正在使用的数据库。Private Sub myRebak()
Dim cn As New ADODB.Connection
With cn
.ConnectionTimeout = 60
.CursorLocation = adUseServer
.Mode = adModeShareExclusive
.Open "Provider=SQLOLEDB; " & _
"Server=" & ServerName & ";" & _
"Database=myinvoice;" & _
"Uid=" & ServerID & ";" & _
"Pwd=" + ServerPassword + ";"
.Execute "use master"
.Execute "alter database myinvoice set SINGLE_USER"
.Execute "restore database myinvoice " & _
"from disk='" & App.Path & "\" & Combo1.Text & ".dat'"
.Execute "alter database myinvoice set MULTI_USER"
.Execute "use myinvoice"
End With
End Sub
Dim cn As New ADODB.Connection
With cn
.ConnectionTimeout = 60
.CursorLocation = adUseServer
.Mode = adModeShareExclusive
.Open "Provider=SQLOLEDB; " & _
"Server=" & ServerName & ";" & _
"Database=myinvoice;" & _
"Uid=" & ServerID & ";" & _
"Pwd=" + ServerPassword + ";"
.Execute "use master"
.Execute "alter database myinvoice set SINGLE_USER"
.Execute "restore database myinvoice " & _
"from disk='" & App.Path & "\" & Combo1.Text & ".dat'"
.Execute "alter database myinvoice set MULTI_USER"
.Execute "use myinvoice"
End With
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货