Esempio n. 1
0
        public static void CreateDatabase()
        {
            string command = @" CREATE DATABASE [EBusiness];

            ALTER DATABASE [EBusiness] SET COMPATIBILITY_LEVEL = 90;

            IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
            begin
            EXEC [EBusiness].[dbo].[sp_fulltext_database] @action = 'enable';
            end

            ALTER DATABASE [EBusiness] SET ANSI_NULL_DEFAULT OFF ;

            ALTER DATABASE [EBusiness] SET ANSI_NULLS OFF ;

            ALTER DATABASE [EBusiness] SET ANSI_PADDING OFF ;

            ALTER DATABASE [EBusiness] SET ANSI_WARNINGS OFF ;

            ALTER DATABASE [EBusiness] SET ARITHABORT OFF ;

            ALTER DATABASE [EBusiness] SET AUTO_CLOSE ON ;

            ALTER DATABASE [EBusiness] SET AUTO_CREATE_STATISTICS ON ;

            ALTER DATABASE [EBusiness] SET AUTO_SHRINK OFF ;

            ALTER DATABASE [EBusiness] SET AUTO_UPDATE_STATISTICS ON ;

            ALTER DATABASE [EBusiness] SET CURSOR_CLOSE_ON_COMMIT OFF ;

            ALTER DATABASE [EBusiness] SET CURSOR_DEFAULT  GLOBAL ;

            ALTER DATABASE [EBusiness] SET CONCAT_NULL_YIELDS_NULL OFF ;

            ALTER DATABASE [EBusiness] SET NUMERIC_ROUNDABORT OFF ;

            ALTER DATABASE [EBusiness] SET QUOTED_IDENTIFIER OFF ;

            ALTER DATABASE [EBusiness] SET RECURSIVE_TRIGGERS OFF ;

            ALTER DATABASE [EBusiness] SET  DISABLE_BROKER ;

            ALTER DATABASE [EBusiness] SET AUTO_UPDATE_STATISTICS_ASYNC OFF ;

            ALTER DATABASE [EBusiness] SET DATE_CORRELATION_OPTIMIZATION OFF ;

            ALTER DATABASE [EBusiness] SET TRUSTWORTHY OFF ;

            ALTER DATABASE [EBusiness] SET ALLOW_SNAPSHOT_ISOLATION OFF ;

            ALTER DATABASE [EBusiness] SET PARAMETERIZATION SIMPLE ;

            ALTER DATABASE [EBusiness] SET READ_COMMITTED_SNAPSHOT OFF ;

            ALTER DATABASE [EBusiness] SET HONOR_BROKER_PRIORITY OFF ;

            ALTER DATABASE [EBusiness] SET  READ_WRITE ;

            ALTER DATABASE [EBusiness] SET RECOVERY FULL ;

            ALTER DATABASE [EBusiness] SET  MULTI_USER ;

            ALTER DATABASE [EBusiness] SET PAGE_VERIFY CHECKSUM  ;

            ALTER DATABASE [EBusiness] SET DB_CHAINING OFF ;
            ";
            try
            {
                DataAccessManager dam = new DataAccessManager();
                SqlConnection conn = dam.GetMasterConnection();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandText = command;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to create Database due to following Exception : " + ex.Message);
            }
        }