/// <summary>
        ///
        /// </summary>
        /// <param name="database">new database name => Required</param>
        /// <param name="comment">Required</param>
        /// <param name="group"></param>
        /// <param name="permissions"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public async Task <CreateDatabase> CreateDatabase(string database, string comment, string group, string permissions, string location)
        {
            if (string.IsNullOrEmpty(database))
            {
                throw new Exception("database and comment are required.");
            }

            CreateDatabaseParam jsonParams = new CreateDatabaseParam
            {
                comment     = comment,
                group       = group,
                permissions = permissions,
                location    = location
            };

            CreateDatabase createDatabase = await Put <CreateDatabase>(_webHcatBaseUrl, _webHCatVersion, _webHCatUserName, requestURL.CreateDatabase(database), jsonParams);

            return(createDatabase);
        }
Ejemplo n.º 2
0
        // This method creates a new SQL Server database
        public bool createDatabase(CreateDatabaseParam tInputParam)
        {
            String str;

            try {
                // Build Create database sql command
                str = "CREATE DATABASE "
                      + tInputParam.sDbName
                      + " ON PRIMARY (NAME = "
                      + tInputParam.sDbName
                      + "_Data, FILENAME = '"
                      + tInputParam.sPath
                      + tInputParam.sDbName
                      + "Data.mdf', SIZE = "
                      + tInputParam.sMDfSize
                      + "MB, MAXSIZE = "
                      + tInputParam.sMDFMaxSize
                      + "MB, FILEGROWTH = "
                      + tInputParam.sMDFPercentFileGrowth
                      + "%) LOG ON (NAME = "
                      + tInputParam.sDbName
                      + "_Log, FILENAME = '"
                      + tInputParam.sPath
                      + tInputParam.sDbName
                      + "Log.ldf', "
                      + "SIZE = "
                      + tInputParam.sLDFSize
                      + "MB, MAXSIZE = "
                      + tInputParam.sLDFMaxSize
                      + "MB, FILEGROWTH = "
                      + tInputParam.sIDFPercentFileGrowth
                      + "%)";

                return(executeSqlStatement(str));
            }
            catch (SqlException ex) {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }