首页 > 编程 > .NET > 正文

ASP.NET或者VB.NET开发自动备份数据库应用程序

2024-07-10 13:03:15
字体:
来源:转载
供稿:网友
'备份数据库

'backupdataname数据库存放的绝对路径

function backupdata(byval backupdataname as string) as string

dim conn as new sqlclient.sqlconnection(modconn.getconn)

dim myselectquery as string = "backup database popcrm to disk ='" & backupdataname & "'"

dim myreader as sqlclient.sqldatareader

dim cmd as new sqlcommand(myselectquery, conn)

if conn.state = connectionstate.closed then conn.open()

try

cmd.executenonquery()

backupdata = ""

catch exsql as sqlexception

if exsql.number = 3201 then

backupdata = "请正确输入备份文件的存放路径!"

else

backupdata = exsql.message

end if

catch ex as exception

backupdata = ex.message

end try

cmd.connection.close()

cmd.dispose()

conn.dispose()

end function
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表