Skip to content
Loading
  • 0
    @ Rajkiran Swain
     
    actually, I have used the following code and it works nicely on my PC but through error on another PC connected through LAN.
     
    FolderBrowserDialog dlg = new FolderBrowserDialog();
    if (dlg.ShowDialog() == DialogResult.OK)
    {
    // textBox1.Text = saveFileDialog1.FileName;
    string strLocation = dlg.SelectedPath;
    string strDB = "BIRD_SMS";
    con = new SqlConnection(strConn);
    con.Open();
    string sql = "BACKUP DATABASE " + strDB + " TO DISK ='" + strLocation + "\\" + strDB + "-" + DateTime.Now.Ticks.ToString() + ".bak'";
    cmd = new SqlCommand(sql, con);
    cmd.ExecuteNonQuery();
    con.Close();
    con.Dispose();
    label1.Text = "";
    btnBackup.Visible = false;
    panel1.Visible = false;
    MessageBox.Show("Database backup completed successfully,\n Please remove previous backup before taking backup again at same location!");
    }
     
    0
  • 0
    Hi Amit,
     
    Read Following link
     
    https://www.howtogeek.com/51788/how-to-backup-sql-databases-to-a-network-share/ 
    0
  • Gokhul Varman
    0
    It is very simple process just follow the instructions given in the referred link:http://sql-articles.com/articles/general/backup-sql-database-to-remote-location/
    0
  • Amit Gupta
    0
    Hey
    Just be assure that the directory must exists before taking backup to the destination.
     
    Debug your code and check the value of your sql variable.
    0