Blank Database Creation

Posted by imomins on March 29, 2011 at 12:41 AM

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.Sql;

using System.Data.SqlClient;

using System.Windows.Forms;

using net.ERP.Constants;

 

namespace net.ERP.DatabaseSchema.DatabaseCreationForServer

{

    class BlankDatabaseCreation:CommonConstants

    {

        public void mpubvCreateDatabase(string pstrServerName)

        {

            SqlConnection lprisqlconnSQLConnection = new SqlConnection("Server=" + pstrServerName + ";Integrated security=SSPI;database=master");

            try

            {

                lprisqlconnSQLConnection.Open();

                SqlCommand lsqlcommSqlCommand = new SqlCommand("CREATE DATABASE " + gmpubcstrDatabaseName, lprisqlconnSQLConnection);

                lsqlcommSqlCommand.ExecuteNonQuery();

            }

            catch (Exception pexpDBCreation)

            {

                MessageBox.Show(pexpDBCreation.ToString(), CommonConstants.gmpubcstrUserConfirmation, MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            finally

            {

                if (lprisqlconnSQLConnection.State == ConnectionState.Open)

                {

                    lprisqlconnSQLConnection.Close();

                }

            }

        }

    }

}

 


Categories: SQL, C#, Personal

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments