0
Guys are having trouble solving this problem! My application is in Windows Forms. I need to perform Backup of data through the application itself, but when I run to perform it informs me of this error.
Note: My backup is on a server on the non-local network
This is my code to perform the backup.
try
{
Cursor = Cursors.WaitCursor;
timer2.Enabled = true;
if ((!System.IO.Directory.Exists(@"C:\\DBBackup")))
{
System.IO.Directory.CreateDirectory(@"C:\\DBBackup");
}
string destdir = "C:\\DBBackup\\SISTEMA_CCA " + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") + ".bak";
cg.con = new SqlConnection(cn.DBconn);
cg.con.Open();
string cb = "backup database SISTEMA_CCA to disk='" + destdir + "'with init,stats=10";
cg.cmd = new SqlCommand(cb);
cg.cmd.Connection = cg.con;
cg.cmd.ExecuteReader();
cg.con.Close();
st1 = LB_Usuario.Text;
st2 = "Backup realizado com sucesso";
cf.LogFunc(st1, System.DateTime.Now, st2);
MessageBox.Show("Operação concluída com sucesso", "Backup - Banco de dados", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Erro ao Fazer o Backup", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
From now on I thank!
Thank you Ricardo Pontual. was a mistake of mine in not observing this detail. thanks worked!
– Lucas_Silva
quiet, we are here to help :)
– Ricardo Pontual