I have an object which has various methods that manipulate data in datasets, some of which get written back to the database.
Where I open a connection I always ensure that the Finally statement includes a test to see if the connection is open and closes it accordingly.
Likewise I do the same with Update connections thus:
In the procedure where the above code belongs, there is some code that runs other methods and if they return True then the update code section runs.
I am finding that if that section returns False the execution quite rightly jumps to the Finally section and performs that test. But the test is showing the Open state has the value 1 and therefore tries to execute the Close method which then error saying the object is not set?
This is right as the code that performs the update has been bypassed so the object would not be set.
Question is why is the open statement returning that it is open? I have been through my code and all the connection.close calls are present?
Where I open a connection I always ensure that the Finally statement includes a test to see if the connection is open and closes it accordingly.
Likewise I do the same with Update connections thus:
Code:
Finally
If m_odaContract.UpdateCommand.Connection.State.Open Then
close the connection
m_odaContract.UpdateCommand.Connection.Close()
End If
End Try
In the procedure where the above code belongs, there is some code that runs other methods and if they return True then the update code section runs.
I am finding that if that section returns False the execution quite rightly jumps to the Finally section and performs that test. But the test is showing the Open state has the value 1 and therefore tries to execute the Close method which then error saying the object is not set?
This is right as the code that performs the update has been bypassed so the object would not be set.
Question is why is the open statement returning that it is open? I have been through my code and all the connection.close calls are present?