Blank Database Creation
|
|
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();
}
}
}
}
}
Post a Comment
Oops!
The words you entered did not match the given text. Please try again.
Oops!
Oops, you forgot something.