31 lines
883 B
C#
31 lines
883 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
public class DbConn {
|
|
protected string _connectionString { get; set; }
|
|
protected SqlConnection _sqlConnection { get; set; }
|
|
|
|
public DbConn() {
|
|
this._connectionString = GlobalClass.appsettings("ConnectionStrings:SQLConnectionString");
|
|
}
|
|
|
|
public SqlConnection sqlConnection() {
|
|
this._sqlConnection = new SqlConnection(this._connectionString);
|
|
if (this._sqlConnection.State != ConnectionState.Open) {
|
|
this._sqlConnection.Open();
|
|
}
|
|
return this._sqlConnection;
|
|
}
|
|
|
|
public void closeConn() {
|
|
if (this._sqlConnection.State != ConnectionState.Closed) {
|
|
this._sqlConnection.Close();
|
|
this._sqlConnection.Dispose();
|
|
}
|
|
}
|
|
}
|