SetOnline() public method

public SetOnline ( string databaseName ) : void
databaseName string
return void
コード例 #1
0
ファイル: DatabaseCreator.cs プロジェクト: Teleopti/Stardust
		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;
			}
		}
コード例 #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;
            }
        }