HanTechneut
Nieuwe gebruiker
- Lid geworden
- 16 jan 2015
- Berichten
- 2
Ik heb de volgende code die blijkbaar niet goed wordt afgesloten. Wat er mis is weet ik niet. De fout wordt omschreven als:
Warning: Microsoft.Reliability : In method 'Form1.Updaten()', call System.IDisposable.Dispose on object 'adapter' before all references to it are out of scope.
Ziet iemand wat er fout aan is?
Dim connection As New OleDb.OleDbConnection(dbInfo)
Dim oleDbUpdateCommand As New OleDb.OleDbCommand()
Try
connection.Open()
Dim adapter As New OleDb.OleDbDataAdapter()
Dim command As String
command = "update VoerTijdenQuery set x1 = " & voermomenten(1, 1) & " where Basin = " & 1 & ""
oleDbUpdateCommand.Connection = connection
oleDbUpdateCommand.CommandText = command
adapter.UpdateCommand = oleDbUpdateCommand
adapter.UpdateCommand.ExecuteNonQuery()
Catch exceptionObject As Exception
MessageBox.Show(exceptionObject.Message)
Finally
connection.Close()
End Try
Warning: Microsoft.Reliability : In method 'Form1.Updaten()', call System.IDisposable.Dispose on object 'adapter' before all references to it are out of scope.
Ziet iemand wat er fout aan is?
Dim connection As New OleDb.OleDbConnection(dbInfo)
Dim oleDbUpdateCommand As New OleDb.OleDbCommand()
Try
connection.Open()
Dim adapter As New OleDb.OleDbDataAdapter()
Dim command As String
command = "update VoerTijdenQuery set x1 = " & voermomenten(1, 1) & " where Basin = " & 1 & ""
oleDbUpdateCommand.Connection = connection
oleDbUpdateCommand.CommandText = command
adapter.UpdateCommand = oleDbUpdateCommand
adapter.UpdateCommand.ExecuteNonQuery()
Catch exceptionObject As Exception
MessageBox.Show(exceptionObject.Message)
Finally
connection.Close()
End Try