I have a service based database called golds.mdf, when I take back up from it, it works fine but the back up does not contain any data.
This is my connection string.
<add name="cs" connectionString="Data Source(LocalDB)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\golds.mdf';Integrated Security=True"/>
This the code for taking back up.
DateTime date1 = DateTime.Today;
var calendar = new System.Globalization.PersianCalendar();
int year = calendar.GetYear(date1);
int month = calendar.GetMonth(date1);
int day = calendar.GetDayOfMonth(date1);
string date12 = string.Format(string.Format("{0}-{1}-{2}", year, month, day));
// string mybackup = "GolShop";
if (BackupPath.Text == string.Empty)
{
MessageBox.Show("لطفا موقعیت نسخه را انتخاب کنید");
}
else
{
int r = 0;
string cmd = "BACKUP DATABASE golds TO Disk = '" + BackupPath.Text + "\\" + "Dataase" + "-" + date12 + ".bak'";
r = database.setData(cmd);
database.closeConnection();
this.Enabled = false;
this.Enabled = true;
MessageBox.Show("Backup done.....");
}
what is the solution to take backup and have the data.