restore
-
hi i use these code for restore
this.openFileDialog1.ShowDialog(); if ((this.openFileDialog1.FileName != "") && (this.openFileDialog1.FileName!="openFileDialog1")) { try { filename = openFileDialog1.FileName; SqlConnection SqlCon = new SqlConnection(); SqlCon.ConnectionString = global::project.Properties.Settings.Default.dabirkhanehConnectionString; SqlCommand SqlCom = new SqlCommand(); SqlCom.Connection = SqlCon; SqlCon.Open(); SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET SINGLE\_USER WITH ROLLBACK IMMEDIATE" +" USE master; RESTORE DATABASE dabirkhaneh FROM DISK =N'"+filename+"'"; SqlCom.Connection = SqlCon; SqlCom.ExecuteNonQuery(); SqlCon.Close(); // \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*// SqlCon.Open(); SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET MULTI\_USER "; SqlCom.Connection = SqlCon; SqlCom.ExecuteNonQuery(); SqlCon.Close(); MessageBox.Show("بازیابی با موفقیت انجام شد"); } catch { MessageBox.Show("بازیابی با موفقیت انجام نشد"); } }
but i have error; The tail of the log for the database "vezaratekar" 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'. please help thanks
-
hi i use these code for restore
this.openFileDialog1.ShowDialog(); if ((this.openFileDialog1.FileName != "") && (this.openFileDialog1.FileName!="openFileDialog1")) { try { filename = openFileDialog1.FileName; SqlConnection SqlCon = new SqlConnection(); SqlCon.ConnectionString = global::project.Properties.Settings.Default.dabirkhanehConnectionString; SqlCommand SqlCom = new SqlCommand(); SqlCom.Connection = SqlCon; SqlCon.Open(); SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET SINGLE\_USER WITH ROLLBACK IMMEDIATE" +" USE master; RESTORE DATABASE dabirkhaneh FROM DISK =N'"+filename+"'"; SqlCom.Connection = SqlCon; SqlCom.ExecuteNonQuery(); SqlCon.Close(); // \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*// SqlCon.Open(); SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET MULTI\_USER "; SqlCom.Connection = SqlCon; SqlCom.ExecuteNonQuery(); SqlCon.Close(); MessageBox.Show("بازیابی با موفقیت انجام شد"); } catch { MessageBox.Show("بازیابی با موفقیت انجام نشد"); } }
but i have error; The tail of the log for the database "vezaratekar" 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'. please help thanks