Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. restore

restore

Scheduled Pinned Locked Moved C#
helpdatabase
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NiloofarNoroozi
    wrote on last edited by
    #1

    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

    W 1 Reply Last reply
    0
    • N NiloofarNoroozi

      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

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      This would be SQL and Database discussions[^] question. However, the error is very clear. Have you tried tail-log backup before restore or forced restore as the error describes?

      The need to optimize rises from a bad design

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups