OracleConnection.Close()

OracleConnection.Close()

Postby 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?
sinys
 
Posts: 181
Joined: Tue 21 Feb 2012 03:44

Postby 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.
Pinturiccio
Devart Team
 
Posts: 1997
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for Oracle