database connection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class DBConn
{
private static SqlConnection Conn;
private DBConn()
{
}
public static SqlConnection getDbConnection()
{
try
{
if (Conn == null)
{
Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["watsandatabaseConnectionString"].ConnectionString);
Conn.Open();
}
else if (Conn.State == ConnectionState.Closed)
{
Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["watsandatabaseConnectionString"].ToString());
Conn.Open();
}
return Conn;
}
catch (Exception)
{
throw;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class DBConn
{
private static SqlConnection Conn;
private DBConn()
{
}
public static SqlConnection getDbConnection()
{
try
{
if (Conn == null)
{
Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["watsandatabaseConnectionString"].ConnectionString);
Conn.Open();
}
else if (Conn.State == ConnectionState.Closed)
{
Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["watsandatabaseConnectionString"].ToString());
Conn.Open();
}
return Conn;
}
catch (Exception)
{
throw;
}
}
}
}
0 comments:
Post a Comment