Database

Alejandro Cernuda



Esistono metodi che definiscono alcune operazioni di base sul database. Microsoft SQL ha una gerarchia ben definita di autorizzazioni e sarà necessaria la gerarchia del proprietario per eseguire questi metodi.

        ///<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;

}

Possiamo creare copie del database

        ///<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;