Bases de dados

Alejandro Cernuda



Existem métodos que definem algumas operações básicas no banco de dados. O Microsoft SQL tem uma hierarquia de permissões bem definida e precisaremos da hierarquia do proprietário para executar esses métodos.

        ///<summary>

/// Connection string to SQLCCTooldatabase with owner permissions.

///</summary>

publicstaticstringConnectionString { get { return"DataSource=(local);Initial Catalog=SQLCCTool ;Integrated Security=true"; }}

 

///<summary>

/// For testing purpose need to createtwo databases SQLCCTool and Copier

/// this method test database change oncontext

///</summary>

///<returns></returns>

publicstaticboolTestChangeDatabase()

        {

try

            {

                DataGather dataGather =DataGather.GetInstance(ConnectionString, "Copier");

                CurrentDatabase currentDatabase =CurrentDatabase.Get(dataGather);

returncurrentDatabase.Name == "Copier";

            }

catch(Exception ex)

            {

returnfalse;

}

Podremos crear copias de la base de datos.

        ///<summary>

/// Creates a backup of database Copier.

///</summary>

///<paramname="path"> backup path. Root path must exist </param>

///<returns></returns>

publicstaticbool TestBackupDatabase( string path)

        {

try

            {               

DataGather dataGather = DataGather.GetInstance(ConnectionString, "Copier");

CurrentDatabase currentDatabase = CurrentDatabase.Get(dataGather);

currentDatabase.BackupWithCompression(path);               

            }

catch (Exception ex)

            {

returnfalse;

}

returntrue;