TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Methoun Ahmed
NA
145
102.3k
Backup Database In Sql database C#
Oct 4 2017 10:38 AM
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
{
}
Reply
Answers (
5
)
How to read data from excel file and store data into MSAcces
csv file to pdf file convertor c#