only open connection if it's closed.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-02-10 11:19:27 -07:00
parent 46a227453e
commit d3f94337ae
17 changed files with 72 additions and 18 deletions

View File

@@ -76,7 +76,10 @@ namespace CarCareTracker.Controllers
try
{
var pgDataSource = new NpgsqlConnection(_configHelper.GetServerPostgresConnection());
pgDataSource.Open();
if (pgDataSource.State == System.Data.ConnectionState.Closed)
{
pgDataSource.Open();
}
InitializeTables(pgDataSource);
//pull records
var vehicles = new List<Vehicle>();
@@ -421,7 +424,10 @@ namespace CarCareTracker.Controllers
try
{
var pgDataSource = new NpgsqlConnection(_configHelper.GetServerPostgresConnection());
pgDataSource.Open();
if (pgDataSource.State == System.Data.ConnectionState.Closed)
{
pgDataSource.Open();
}
InitializeTables(pgDataSource);
//pull records
var vehicles = new List<Vehicle>();