Databases

Alejandro Cernuda



There are methods that define some basic operations on the database. Microsoft SQL has a well-defined hierarchy of permissions and we will need the owner hierarchy to execute these methods.

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

}

We can create backups of the 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;