public void CreateDatabase(string connectionName = null) { string databaseName = ConnectionProviderBase.GetDatabaseName(connectionName); string sqlTemplate = "CREATE DATABASE {0}"; string sqlText = string.Format(sqlTemplate, databaseName); string connStr = SqlServerConnectionProvider.Instance.GetConnectionStringWithoutIC(connectionName); SqlServerBaseOrder.ExecuteNonQuery(connStr, sqlText); }
public bool DatabaseExist(string connectionName = null) { string databaseName = ConnectionProviderBase.GetDatabaseName(connectionName); string sqlTemplate = "SELECT * FROM master.dbo.sysdatabases WHERE name='{0}'"; string sqlText = string.Format(sqlTemplate, databaseName); string connStr = SqlServerConnectionProvider.Instance.GetConnectionStringWithoutIC(connectionName); object result = SqlServerBaseOrder.ExecuteScalar(connStr, sqlText); if (result != null && string.Equals(result as string, databaseName)) { return(true); } return(false); }