

























2010-07-28 21:36 zhangbaoyu 阅读(345) 评论() 收藏 举报
Dim strcon As String
Dim strsql As String
Dim con As SqlConnection
Dim com As SqlCommand
Dim databasepath As String
Dim pos As Integer
databasepath = Application.ExecutablePath
pos = InStrRev(databasepath, "\ ")
databasepath = Mid(databasepath, 1, pos) & "backup\databaseback.bak "
strcon = "server=localhost;database=humanadministration;uid=cxl;pwd=cxl; "
con = New SqlConnection(strcon)
strsql = "backup database yourdatabase to disk= ' " & databasepath & " ' "
com = New SqlCommand(strsql, con)
Try
con.Open()
com.ExecuteNonQuery()
MessageBox.Show( "数据库备份成功! ", "信息提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "错误提示: ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Finally
con.Close()
End Try
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。