VB的数据库还原问题
Dim conn As New ADODB.ConnectionDim rs As New ADODB.Recordset
Private Sub Command1_Click()
CommonDialog1.Filter = "备份文件(*.bak)|*.bak|文本文件(*.txt)|*.txt|all file(*.*)|*.*"
CommonDialog1.ShowSave
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
Me.MousePointer = 11
Command2.Enabled = False
If Text1.Text = "" Then
MsgBox "请您选择数据库恢复的路径", 64, "提示信息"
Else
Dim connter As Integer
Dim sql, workarea(6) As String
ProgressBar1.Visible = True
ProgressBar1.Max = UBound(workarea)
ProgressBar1.Value = ProgressBar1.Min
For connter = LBound(workarea) To UBound(workarea)
workarea(connter) = "initial value" & connter
ProgressBar1.Value = connter
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=DONG\MAAQL2008"
sql = "use master restore database 恢复的 from disk='" & Text1.Text & "'"
conn.Execute (sql)
conn.Close
Next connter
ProgressBar1.Value = ProgressBar1.Min
MsgBox "数据库恢复", 64, "提示信息"
Command2.Enabled = True
Me.MousePointer = 0
End If
End Sub
Private Sub Command3_Click()
End
End Sub
这是我的代码,,“恢复的”是我的数据库名,打算在这个空数据库里面还原一个shili.bak的备份文件。代码运行没有问题,但是每次还原成功后在“恢复的”数据库里找不到数据