locked
restore log hiba elkapasa RRS feed

  • Question

  • az a bajom, hogy nem tudom elkapni a pontos hibat,

    ha "too early", akkor folytatnam a futast a kov TRN fajllal, de ha mas baja van akkor megallnek.

    de a 

    begin try

     restore log....

    end try

    begin catch

     print ERROR_NUMBER()

    end catch

    mindig az ucso hibat adja vissza, a 3013-at, azaz nem tudom, hogy miert nem sikerult.

    honna lehet ezt megtudni?

     

    Msg 3101, Level 16, State 1, Line 1

    Exclusive access could not be obtained because the database is in use.

    Msg 3013, Level 16, State 1, Line 1

    RESTORE LOG is terminating abnormally.

    Msg 3201, Level 16, State 2, Line 1

    Cannot open backup device 'D:\data\data_srv\dbagroup\mssql\MSSQL.1\MSSQL\Backup\icFlex_20070525060005.trn'. Operating system error 2(The system cannot find the file specified.).

    Msg 3013, Level 16, State 1, Line 1

    RESTORE LOG is terminating abnormally.

    Msg 4305, Level 16, State 1, Line 1

    The log in this backup set begins at LSN 81583000000837500001, which is too recent to apply to the database. An earlier log backup that includes LSN 81167000005326000001 can be restored.

    Msg 3013, Level 16, State 1, Line 1

    RESTORE LOG is terminating abnormally.

    Saturday, May 26, 2007 7:54 AM

Answers

  • dotnetben tudod elkapni csak:

     

    public void teszt

    {

    using (SqlConnection sqlconn = new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;" +

    "Initial Catalog=tempdb;"))

    {

    sqlconn.InfoMessage += new SqlInfoMessageEventHandler(MessageEventHandler);

    sqlconn.Open();

    SqlCommand sqlCommand = new SqlCommand("restore log AdventureWorks", sqlconn);

    try

    {

    sqlCommand.ExecuteNonQuery();

    }

    catch (SqlException ee)

    {

    foreach (SqlError sqlError in ee.Errors)

    {

    Console.WriteLine(sqlError.Number.ToString() + "," + sqlError.Message);

    }

    }

    finally

    {

    sqlCommand.Dispose();

    }

    }

    }

     

    //ez itt az info msg-hez kell

    public static void MessageEventHandler(object sender, SqlInfoMessageEventArgs e)

    {

    foreach (SqlError error in e.Errors)

    {

    Console.WriteLine("vlm warning jött: " + error);

    }

    }

    Tuesday, May 29, 2007 8:23 AM
    Moderator

All replies

  • dotnetben tudod elkapni csak:

     

    public void teszt

    {

    using (SqlConnection sqlconn = new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;" +

    "Initial Catalog=tempdb;"))

    {

    sqlconn.InfoMessage += new SqlInfoMessageEventHandler(MessageEventHandler);

    sqlconn.Open();

    SqlCommand sqlCommand = new SqlCommand("restore log AdventureWorks", sqlconn);

    try

    {

    sqlCommand.ExecuteNonQuery();

    }

    catch (SqlException ee)

    {

    foreach (SqlError sqlError in ee.Errors)

    {

    Console.WriteLine(sqlError.Number.ToString() + "," + sqlError.Message);

    }

    }

    finally

    {

    sqlCommand.Dispose();

    }

    }

    }

     

    //ez itt az info msg-hez kell

    public static void MessageEventHandler(object sender, SqlInfoMessageEventArgs e)

    {

    foreach (SqlError error in e.Errors)

    {

    Console.WriteLine("vlm warning jött: " + error);

    }

    }

    Tuesday, May 29, 2007 8:23 AM
    Moderator
  • rossz hir Sad

    koszi.

    Thursday, May 31, 2007 8:19 PM