OracleConnection.Close()

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

OracleConnection.Close()

Post by sinys » Tue 21 Feb 2012 04:00

When I write in this stile:

Code: Select all

            using (OracleConnection c = new OracleConnection(connString))
                {

                    c.Open();

                    string commandQuery = @"select lpu.x.y(:pLid, :pRid) from dual";
                    using (OracleCommand cmd = new OracleCommand(commandQuery, c))
                    {
                        cmd.Parameters.Add("pLid", key.lid);
                        cmd.Parameters.Add("pRid", rid);
                        return Convert.ToDecimal(cmd.ExecuteScalar());
                    }
                }
when block "using" ended automatically call c.Close()? or I must write this?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Tue 21 Feb 2012 13:27

OracleConnection class inherit IDisposable interface, so you can use inside the using block. So c.Close() will be called automatically in the end of the using block.

Post Reply