using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace DALBlueWhale
{
public class ConnectionProvider
{
SqlConnection _connection;
private string connStr = "";
public ConnectionProvider()
{
connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
}
public ConnectionProvider(string con_string)
{
this.connStr = con_string;
}
public string ConnectionString
{
get { return connStr; }
set { connStr = value; }
}
/// <summary>
/// creates sqlconnection object using given connection sting and returns sqlconnection object
/// </summary>
/// <returns>SqlConnection object</returns>
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void ConnectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace DALBlueWhale
{
public class ConnectionProvider
{
SqlConnection _connection;
private string connStr = "";
public ConnectionProvider()
{
connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
}
public ConnectionProvider(string con_string)
{
this.connStr = con_string;
}
public string ConnectionString
{
get { return connStr; }
set { connStr = value; }
}
/// <summary>
/// creates sqlconnection object using given connection sting and returns sqlconnection object
/// </summary>
/// <returns>SqlConnection object</returns>
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void ConnectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
}
0 comments:
Post a Comment