标题:VB的数据库还原问题
只看楼主
gumengyin
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2014-3-19
结帖率:66.67%
 问题点数:0 回复次数:0 
VB的数据库还原问题
Dim conn As New ADODB.Connection
Dim 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的备份文件。代码运行没有问题,但是每次还原成功后在“恢复的”数据库里找不到数据
搜索更多相关主题的帖子: 文本文件 提示信息 数据库 file 
2014-04-04 22:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429705-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.158669 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved