Disposing BDP objects
Wednesday, May 24, 2006 06:30 PM
One of the tasks in the BDN 2 project was migrating the old BDN content from the Oracle database where it was stored. Of course, we wrote a migration program using Delphi and accessed the database using BDP. When running the migration, however, we kept getting errors from Oracle: the program was opening cursors but not closing them. The BDP documentation isn't very detailed, but BDP is simply an ADO.NET provider, so what works on other providers should work with BDP, right?
Well, not exactly. For the providers included in the .NET framework, you're required to call Close for any command or data reader object. Turns out this isn't enough for BDP - you also have to dispose of the object. You can do so by explicitly calling the Dispose method. If you're using Delphi, calling Free automatically calls Dispose for you. So, if you're accessing Oracle using BDP, make sure to call Dispose or Free when you're done with the object (you should probably do that with other databases as well, but I've only seen the open cursors issue with Oracle so far).