SetOnline() public méthode

public SetOnline ( string databaseName ) : void
databaseName string
Résultat void
Exemple #1
0
		public void CreateDatabase(string scriptFilePath, string databaseName)
		{
			var tasks = new DatabaseTasks(_executeMaster);
			if (tasks.Exists(databaseName))
			{
				tasks.SetOnline(databaseName); // if dropping a database that is offline, the file on disk will remain!
				_executeMaster.ExecuteTransactionlessNonQuery(
					string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;", databaseName));
				tasks.Drop(databaseName);
			}


			try
			{
				var script = File.ReadAllText(scriptFilePath + "CreateDB.sql");
				script = ReplaceScriptTags(script, databaseName);
				_executeMaster.ExecuteTransactionlessNonQuery(script, 10800);
			}
			catch (Exception exception)
			{
				string msg = exception.StackTrace;
			}
		}
Exemple #2
0
        public void CreateDatabase(string scriptFilePath, string databaseName)
        {
            var tasks = new DatabaseTasks(_executeMaster);

            if (tasks.Exists(databaseName))
            {
                tasks.SetOnline(databaseName);                 // if dropping a database that is offline, the file on disk will remain!
                _executeMaster.ExecuteTransactionlessNonQuery(
                    string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;", databaseName));
                tasks.Drop(databaseName);
            }


            try
            {
                var script = File.ReadAllText(scriptFilePath + "CreateDB.sql");
                script = ReplaceScriptTags(script, databaseName);
                _executeMaster.ExecuteTransactionlessNonQuery(script, 10800);
            }
            catch (Exception exception)
            {
                string msg = exception.StackTrace;
            }
        }