下面的代码要怎么修改?急啊。
Dim cn As New ADODB.Connection cn.ConnectionString = "provider=SQLOLEDB;server=(local);uid=sa;pwd="
cn.CursorLocation = adUseClient
cn.Open
cn.Execute "BACKUP DATABASE bak TO DISK = 'c:\mssql7\backup\bak.bak'"
MsgBox "备份成功!"
cn.Execute "RESTORE DATABASE bak FROM DISK = 'c:\mssql7\backup\bak.bak' with replace"
MsgBox "恢复成功!"
cn.Close: Set cn = Nothing
我用上面的语句做备份成功了,可是做还原的时候,vb报错说“因为数据库正在使用,所以未能获得对数据库的排它访问权”怎么解决啊?高手帮忙啊!!!!