Adjusted open and close connections

This commit is contained in:
DanBribi 2021-12-14 14:41:37 -08:00
parent 04f5d9856b
commit 68b8439256
2 changed files with 8 additions and 7 deletions

View File

@ -209,7 +209,7 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
if (sqlDAO.GetType() == typeof(SqlDAO)) if (sqlDAO.GetType() == typeof(SqlDAO))
{ {
sqlDS = (SqlDAO)sqlDAO; sqlDS = (SqlDAO)sqlDAO;
sqlDS.GetConnection().Open(); //sqlDS.GetConnection().Open();
// Act // Act
Console.WriteLine("\nInserting into archive..."); Console.WriteLine("\nInserting into archive...");
@ -249,7 +249,7 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
Console.WriteLine("\nExpected: {0}, Actual: {1}. Entries not removed.", expectedVal, actualVal); Console.WriteLine("\nExpected: {0}, Actual: {1}. Entries not removed.", expectedVal, actualVal);
} }
sqlDS.GetConnection().Close(); //sqlDS.GetConnection().Close();
} }
return; return;
@ -299,6 +299,7 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
"PASSWORD=Teamhobby;" + "PASSWORD=Teamhobby;" +
"OPTION=3"; "OPTION=3";
SqlDAO sqlDAO = new SqlDAO(dbInfo); SqlDAO sqlDAO = new SqlDAO(dbInfo);
sqlDAO.GetConnection().Open();
//ArchiveManager archiveManager = new ArchiveManager(sqlDAO); //ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
// Testing folder creation // Testing folder creation
@ -333,7 +334,7 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
test.RemoveOutputFileTest(sqlDAO); test.RemoveOutputFileTest(sqlDAO);
Console.WriteLine("-----------------"); Console.WriteLine("-----------------");
Console.WriteLine(""); Console.WriteLine("");
sqlDAO.GetConnection().Close();
} }
} }

View File

@ -177,7 +177,7 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
public bool CopyToFile(string filePath){ public bool CopyToFile(string filePath){
try try
{ {
_conn.Open(); //_conn.Open();
// Conver backward slash in to forward slash // Conver backward slash in to forward slash
filePath = filePath.Replace("\\", "/"); filePath = filePath.Replace("\\", "/");
string sqlQuery = "SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage' " + string sqlQuery = "SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage' " +
@ -200,19 +200,19 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
Console.WriteLine("Output to a file completed. "); Console.WriteLine("Output to a file completed. ");
_conn.Close(); //_conn.Close();
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
_conn.Close(); //_conn.Close();
Console.WriteLine("Error when copying query to a file !!, will be handled higher up the call stack"); Console.WriteLine("Error when copying query to a file !!, will be handled higher up the call stack");
throw; throw;
} }
finally finally
{ {
_conn.Close(); //_conn.Close();
} }
} }