本文介绍了如何进行数据库备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有
如何在sql server 2008中进行数据库备份
我的数据库位置: C:\Program Files \ Microsoft SQL Server \ MSSQL10.SQLEXPRESS \ MSSQL \DATA\Test.mdf
i am using using Button。当我点击命令按钮,那时我想在D:\ BackupFount数据库中保存数据库。\\ test.mdf
请告诉我..我是怎么做的
Dear All
How to Make Database Backup in sql server 2008
my database location : C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Test.mdf
i am using command Button. When i click Command Button that time i want to store database in D:\Backup Database\Test.mdf
Please tell me.. how i do for this
推荐答案
'backup database
Try
Dim backupdate, newname As String
'backup database
backupdate = DateString
newname = "C:\backup\dbase" & "" + backupdate + "" & ".mdf"
'check if a current day backup exist
If System.IO.File.Exists(newname) Then
'if yes, delete the former backup and backup the new one the new one
System.IO.File.Delete(newname)
System.IO.File.Copy(Application.StartupPath & "\db\dbase.mdf", newname)
Else
'backup database
System.IO.File.Copy(Application.StartupPath & "\db\dbase.mdf", newname)
End If
Dim mymsg As New myMsgbox
'show that backup is successful
With mymsg
.txtError.Text = "Database Backup Successful!"
.ShowDialog()
End With
Catch ex As Exception
Dim mymsg As New myMsgbox
'show an error when backup is not successful
With mymsg
.txtError.Text = "Error Backing Up Database, try again later!"
.ShowDialog()
End With
End Try
这篇关于如何进行数据库备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!