PDA

View Full Version : سوال: مشکل در Restore کردن فایل BackUp



veniz2008
دوشنبه 05 تیر 1391, 16:36 عصر
سلام دوستان،من برای برگرداندن بک آپ (restore ) از پروسیجر و کدهای زیر استفاده میکنم ولی خطا میده،من کدها و متن خطا رو میزارم لطفا بگید مشکل کار از کجاست.،ممنون.
کد پروسیجر:

ALTER proc [dbo].[ReStoreBackUp]
@PathFile nvarchar(300)
As
set @PathFile= REPLACE(@PathFile ,'\\','\')
Begin
ALTER DATABASE [tel] SET OFFLINE WITH ROLLBACK IMMEDIATE
Restore Database [tel] From Disk =@PathFile
End



کدهای داخل محیط ویژوال:

SqlConnection con = new SqlConnection("Data Source = (local);Initial Catalog=tel;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "ReStoreBackUp";
cmd.Parameters.AddWithValue("@PathFile", txtpath.Text);
cmd.ExecuteNonQuery();
con.Close();
متن خطا: به کد cmd.ExecuteNonQuery(); ایراد زیر رو میگیره:

The tail of the log for the database "tel" 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.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Failed to restart the current database. The current database is switched to master.