vb中能进行数据库备份吗?

hantaor 2001-09-15 03:49:56
vb中能进行数据库备份吗?数据库备份的方法怎么样?
...全文
83 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
westgirl 2001-11-26
我可不可以问你一个问题(请教关于有vb程序在sqlsever中创建视图):
我写了这样的语句:sql12 = "CREATE VIEW dbjl1" & _
" AS" & _
" SELECT dbjl.jmh AS jmh1, jmk.jj AS jj1, jmk.bt AS bt1, jmk.gslx" & _
" FROM dbjl INNER JOIN" & _
" jmk ON dbjl.jmh = jmk.jmh"
执行后,总出现这样的错误:
实时错误'-2147217865(80040e37)':
[microsoft][odbc sql server driver][sql server]
invalod object name 'gbzb'
回复
zjg751206 2001-11-26
SQL Server可以使用SQL-DMO来做:
恢复数据库:
Private Sub Command2_Click()
Dim sFile As String
sFile = "N_1"

Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oRestore As New SQLDMO.Restore

oServer.Connect servername, username, password
With oRestore

.Files = sFile

.Database = "Northwind"
.ReplaceDatabase = True
.SQLRestore oServer
End With

Set oRestore = Nothing
Set oDatabase = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox ("OK")

End Sub

备份:
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"
oBackup.Devices = "[NorthDev1],[NorthDev2]"
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."

oBackup.SQLBackup oSQLServer


如果你按照上述方法做好一个通用的过程把原代码给我看看!!
我也是抄来的我不懂vb,
zjg751206@sina.com.cn或zjgnj@263.net
回复
yhshu 2001-11-26
当然可以进行备份,只要调用T-SQL构成的stored procedure即可
回复
westgirl 2001-11-26
我刚刚作完数据库备份,运行通过,供你参考:
If cn.State = adStateOpen Then cn.Close
cn.ConnectionTimeout = 10
connstr = "Driver={SQL Server};Server=" & LocalServer & ";UID=" & LocalUser & ";PWD=" & LocalPw & ";DATABASE=" & LocalDb
cn.Open connstr
dd = Date
sql = "BACKUP DATABASE xhj TO disk='D:\mssql7\backup\xhj" & Trim(dd) & "'"
cn.Execute (sql)
回复
visualvbjava 2001-09-15
DBEngine.CompactDatabase "old.mdb", "new.mdb", dbLangGeneral
回复
Jneu 2001-09-15
能啊。
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2001-09-15 03:49
社区公告
暂无公告