none
Recover oracle database RRS feed

  • Question

  • Hi All,

    I want to write a C# application where I want to write command to recover database.

    e.g. recover database;, alter database open;, shutdown immediate; etc.

    If i connect to Sys user and fire these command using ORACLECLIENT, I am getting INVALID SQL COMMAND error.

    Really need a way how to fire these commands. Do I need to refer any different DLL or Component? Please help me

    Thanks for any help in advance.

    Tuesday, March 26, 2019 4:57 AM

All replies

  • Hi Amolpb,
    WCF forum mainly discuss and ask questions about general managed code networking topics such as serialization, System.NET, Windows Communication Foundation(WCF), and Web Services.
    As for how to manipulate the oracle database by using C#, as far as I know, the third party DLL is needed, you could refer to the following link.
    https://www.oracle.com/technetwork/articles/dotnet/index.html
    https://www.oracle.com/technetwork/topics/dotnet/latest-news/index.html
    Best Regards
    Abraham
    Tuesday, March 26, 2019 8:37 AM
    Moderator
  • Hi Amolpb,

    I'll suggest that you use the ODP client to connect to the Oracle database server and execute a SQL command that will execute code to restore the database:

    using System;
    using System.Data;
    using Oracle.DataAccess.Client; 
     
    class OracleConnectionSample
    {
      static void Main()
      {  
        // Connect
        string constr = "User Id=scott;Password=tiger;Data Source=oracle";
        using(OracleConnection connnection = new OracleConnection(constr)){
           using(var command = connection.CreateCommand()){
              command.CommandText = "RECOVER DATABASE
               UNTIL TIME '1992-12-31:12:47:30' USING BACKUP CONTROLFILE;"
               connection.Open()
               var result = command.ExecuteNonQuery();
               connection.Close();     
           }
        }

    anyway, you should adapt the code to your required recovery method, here is an article about restoring databases on Oracle, and here is the guide to install and use the Oracle Data Provider for .net

    Note: just as Abraham suggested, you should first try to search on Oracle site since the provider while it implements .Net's interfaces, the library itself is an Oracle product, and then there is more chance to find a solution.

    Good Coding;

    Tuesday, March 26, 2019 3:50 PM
  • You should post to an Oracle forum.
    Wednesday, March 27, 2019 3:35 AM