با سلام خدمت استاد عزیزم .
من فرم تهیه پشتیبان را به این صورت کد نویسی کردم ولی موقع تهیه نسخه پشتیبان این خطا رو بهم میده
(system.data.sqlclint.sqlexeption(0x80131904
namespace Accounting
{
public partial class frmBackUp : Form
{
string connectionstring = @"Data Source = DESKTOP - 0QCDG6B\SQLEXPRESS;Initial Catalog = AccountindDB; Persist Security Info=True;User ID = sa; Password=hesab.IR@2047";
public static string fileName = DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString();
public string Location = Application.StartupPath + @"\BackUp" + @"\" + fileName;
public frmBackUp()
{
InitializeComponent();
}
private void Caluculate(int i)
{
double pow = Math.Pow(i, i);
}
private void btnGenerateBackUp_Click(object sender, EventArgs e)
{
string query = @"BACKUP DATABASE[AccountindDB] TO DISK =' "+Location+"'";
SqlConnection connection = new SqlConnection(connectionstring);
SqlCommand command = new SqlCommand(query, connection);
try
{
connection.Open();
command.ExecuteNonQuery();
label1.Text = "تهیه نسخه پشتیبان با موفقیت انجام شد";
}
catch (Exception ex)
{
label1.Text = ex.ToString();
}
finally
{
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
prBackUp.Maximum = 100000;
prBackUp.Step = 1;
for (int j = 0; j < 100000; j++)
{
Caluculate(j);
prBackUp.PerformStep();
}
}
private void frmBackUp_Load(object sender, EventArgs e)
{
if (!Directory.Exists(Location))
{
Directory.CreateDirectory(Location);
}
txtBakName.Text = Location;
}
}
}