We have a simple loop that does some things on some datarows.
When making changes, the new line and SqlConnection object are passed to the method that processes the change or addition of the line.
The process runs 5 times out of 10. SqlConnection opens at the beginning of the loop and closes after the loop, however sometimes it does close during the loop. The code does not call the close () function at any point in the loop.
So, my questions are explained by why it can close itself.
Greetings
For reference, the code is similar to the following
connection.Open();
foreach(DataRow row in rows)
{
if(rubbish)
{
DatabaseConnector.Save(sqlStringToExecute, connection);
}
}
connection.Close();
source
share