Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
5
Reply
Backup Database In Sql database C#
Methoun Ahmed
6 years ago
170
Reply
Whats wrong the code
string database = con.Database.ToString();
try
{
if(textBox1.Text==string.Empty)
{
MessageBox.Show("Enter your backup file location");
}
else
{
string cmd = "BACKUP DATABASE[" + database + "] TO DISK '" + textBox1.Text + "\\" + "Database" + "-" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".back'";
using(SqlCommand cmd2=new SqlCommand(cmd,con))
{
if(con.State!=ConnectionState.Open)
{
con.Open();
}
cmd2.ExecuteNonQuery();
con.Close();
MessageBox.Show("Database Backup Successfully");
btnBackup.Enabled = false;
}
}
}
catch
{
}
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
How to read data from excel file and store data into MSAcces
csv file to pdf file convertor c#