ammarkarimi
جمعه 05 مهر 1387, 16:27 عصر
من با کد زیر رستور می کنم که اررور زیر رو می ده :
خطا :
The tail of the log for the database "dabirkhane" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.RESTORE DATABASE is terminating abnormally.Changed database context to 'master'.
کد رستور :
try
{
SqlConnection SqlCon = new SqlConnection("server=.\\SQLEXPRESS; database=dabirkhane; integrated security=true");
SqlCommand SqlCom = new SqlCommand();
SqlCon.Open();
SqlCom.CommandText =
@"ALTER DATABASE dabirkhane SET SINGLE_USER WITH ROLLBACK IMMEDIATE" +
" USE master; RESTORE DATABASE dabirkhane FROM DISK ='" + txt_path_restore.Text + "'";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
//*******************
SqlCon.Open();
SqlCom.CommandText =
"ALTER DATABASE dabirkhane SET MULTI_USER";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
MessageBox.Show("بازگردانی اطلاعات با موفقیت انجام شد");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
خطا :
The tail of the log for the database "dabirkhane" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.RESTORE DATABASE is terminating abnormally.Changed database context to 'master'.
کد رستور :
try
{
SqlConnection SqlCon = new SqlConnection("server=.\\SQLEXPRESS; database=dabirkhane; integrated security=true");
SqlCommand SqlCom = new SqlCommand();
SqlCon.Open();
SqlCom.CommandText =
@"ALTER DATABASE dabirkhane SET SINGLE_USER WITH ROLLBACK IMMEDIATE" +
" USE master; RESTORE DATABASE dabirkhane FROM DISK ='" + txt_path_restore.Text + "'";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
//*******************
SqlCon.Open();
SqlCom.CommandText =
"ALTER DATABASE dabirkhane SET MULTI_USER";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
MessageBox.Show("بازگردانی اطلاعات با موفقیت انجام شد");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}