예제 #1
0
 private void BTM_RESTORE_BACKUP_Click(object sender, EventArgs e)
 {
     try
     {
         string strQuery = "ALTER Database productDB SET OFFLINE WITH ROLLBACK IMMEDIATE ; Restore Database productDB From Disk='" + TXT_FILE_NAME.Text + "'";
         cmd = new SqlCommand(strQuery, con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         MessageBox.Show("تم استعاده النسخه الاحتياطيه بنجاح", "استعاده النسخه احتياطيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TXT_FILE_NAME.Clear();
         TXT_FILE_NAME.Focus();
     }
     catch
     {
         MessageBox.Show("حدث خطا !", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void BTM_CREATE_BACKUP_Click(object sender, EventArgs e)
 {
     try
     {
         string filename = TXT_FILE_NAME.Text + "\\productDB" + DateTime.Now.ToShortDateString().Replace('/', '-')
                           + " - " + DateTime.Now.ToLongTimeString().Replace(':', '-');
         string strQuery = "Backup Database productDB to Disk='" + filename + ".bak'";
         cmd = new SqlCommand(strQuery, con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         MessageBox.Show("تم انشاء النسخه الاحتياطيه بنجاح", "انشاء نسخه احتياطيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TXT_FILE_NAME.Clear();
         TXT_FILE_NAME.Focus();
     }
     catch
     {
     }
 }