0

When I make a backup using C# and SQL Server it gives this error

System.Data.SqlClient.SqlException: 'Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The backup or restore was aborted.'

the code

SqlConnection conn = new SqlConnection(@"Server=" + Properties.Settings.Default.Server + "; Database=" +
                                                    Properties.Settings.Default.Database + "; Integrated Security=false; User ID=" +
                                                    Properties.Settings.Default.ID + "; Password=" + Properties.Settings.Default.Password + "" + ";Connection Timeout = 3600");

string fileName = txtFileName.Text + "\\Archive" + DateTime.Now.ToShortDateString().Replace('/', '-')
                                + " - " + DateTime.Now.ToLongTimeString().Replace(':', '-');
                string strQuery = "Backup Database Archive to Disk='" + fileName + ".bak'";
                cmd = new SqlCommand(strQuery, conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                query(strQuery);
                conn.Close();
Dale K
  • 25,246
  • 15
  • 42
  • 71

0 Answers0