Beispiel #1
0
        private void CreateDatabase()
        {
            try
            {
                AppendLogLine("");
                AppendLogLine(string.Format("Creating a Analysis database: {0} ...", CbDbName));

                _CbServer.Update();
                if (_CbServer.Databases.Contains(CbDbName))
                {
                    AppendLogLine(string.Format("Analysis database: [{0}] already exists, drop it?.", CbDbName));

                    if (MessageBox.Show(string.Format("The Analysis database '{0} - {1}' already exists. Do you want to drop it?", CbServerName, CbDbName),
                                        "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        _CbDatabase = _CbServer.Databases.GetByName(CbDbName);
                        _CbDatabase.Drop();
                    }
                    else
                    {
                        throw new Exception(string.Format("The Analysis database '{0} - {1}' already exists, but user did not want to drop it. Aborting procedure.",
                                                          CbServerName, CbDbName));
                    }
                }

                _CbDatabase = new Database();
                //_CbServer.Databases.GetNewName(CbDbName)
                _CbDatabase = _CbServer.Databases.Add(CbDbName);
                //Save Database to the Analysis Services.
                _CbDatabase.Update();
            }
            catch (Exception ex)
            {
                AppendLogLine("Error in creating a analysis database. Error Message -> " + ex.Message);
                throw;
            }
        }