Bases de datos
Alejandro Cernuda
TweetHay métodos que definen algunas operaciones básicas sobre la base de datos. Microsoft SQL tiene una jerarquía de permisos bien definida y necesitaremos el de owner para ejecutar estos 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;