From: Peter S. <sz...@us...> - 2004-04-08 07:56:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11213/NHibernate.Test Modified Files: TestCase.cs Log Message: I think we may need this for later use :) Index: TestCase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TestCase.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestCase.cs 7 Apr 2004 21:24:21 -0000 1.5 --- TestCase.cs 8 Apr 2004 07:43:29 -0000 1.6 *************** *** 43,46 **** --- 43,78 ---- new SchemaExport(cfg).Drop(true, true); } + public void ExecuteStatement(string sql) + { + ExecuteStatement(sql, true); + } + + public void ExecuteStatement(string sql, bool error) + { + SqlConnection conn = null; + SqlTransaction tran = null; + try + { + conn = new SqlConnection("Server=localhost;initial catalog=nhibernate;User ID=someuser;Password=somepwd"); + conn.Open(); + tran = conn.BeginTransaction(); + System.Data.SqlClient.SqlCommand comm = conn.CreateCommand(); + comm.CommandText = sql; + comm.Transaction = tran; + comm.CommandType = CommandType.Text; + comm.ExecuteNonQuery(); + tran.Commit(); + } + catch + { + tran.Rollback(); + if (error) + throw; + } + finally + { + conn.Close(); + } + } } |