this is my powershell code :
[void][System.Reflection.Assembly]::LoadFile(\"C:\\DLL\\Oracle.ManagedDataAccess.dll\")
$OracleConnexion = New-Object Oracle.Ma
More standard implementation for resource which implement IDisposable
is by wrapping it by using
:
using (OracleConnection connection = new OracleConnection(connectionString)){
using (OracleCommand command = new OracleCommand(sql, connection))
using (OracleDataReader reader = cmd.ExecuteReader())
{
}
connection.Close(); //optional
}
It is equivalent to implementing .Dispose
after the execution block. Internally, Dispose
will also handle the closing. Nevertheless, you could also call the .Close()
after the command block.
A sample in the oracle documentation which uses Oracle.DataAccess
encourages the use of Dispose
too.