From: Paul H. <pha...@us...> - 2005-03-14 22:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Id Modified Files: TableGenerator.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TableGenerator.cs 11 Feb 2005 05:12:34 -0000 1.16 --- TableGenerator.cs 14 Mar 2005 22:41:16 -0000 1.17 *************** *** 130,133 **** --- 130,134 ---- IDbCommand qps = conn.CreateCommand(); + IDataReader rs = null; qps.CommandText = query; qps.CommandType = CommandType.Text; *************** *** 135,139 **** try { ! IDataReader rs = qps.ExecuteReader(); if( !rs.Read() ) { --- 136,140 ---- try { ! rs = qps.ExecuteReader(); if( !rs.Read() ) { *************** *** 142,148 **** throw new IdentifierGenerationException( err ); } - result = Convert.ToInt32( rs[ 0 ] ); - rs.Close(); } // TODO: change to SqlException --- 143,147 ---- *************** *** 154,157 **** --- 153,158 ---- finally { + if ( rs != null ) rs.Close(); + qps.Dispose(); } *************** *** 175,178 **** --- 176,180 ---- finally { + ups.Dispose(); } *************** *** 183,188 **** return result; - } finally { --- 185,190 ---- return result; } + // TODO: Shouldn't we have a Catch with a rollback here? finally { |