PerViewEntities db = new PerViewEntities();
db.Dispose();SqlCommand oCommand = null;
SqlCoection oCoection = null;
try
{
string ConectionString =
@"Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirector y|PerView.mdf;Integrated Security=True;User Instance=True";
string Command = @"backup database [" + Application.StartupPath + "\PerView.mdf] to disk ='" +strFileName + "' with init,stats=10";this.Cursor = Cursors.WaitCursor;oCoection = new SqlCoection(ConectionString);
if (oCoection.State != CoectionState.Open)
oCoection.Open();oCommand = new SqlCommand(Command, oCoection);
oCommand.ExecuteNonQuery();this.Cursor = Cursors.Default;
MessageBoxFarsi.Show("از اطلاعات بانک نسخه پشتیبانی تهیه شد.");
}
catch (Exception ex)
{
MessageBoxFarsi.Show("خطا :" + ex.Message);
}
finally
{
oCoection.Close();
//oCommand.Parameters.Clear();
oCommand.Dispose();
}
برچسب: میگرفتم,
نویسنده: محمد رضا جوادیان