public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // executing your sql query _con.Execute_SQLQuery( "delete from \"CRD_User\" where \"IDUser\" = -1" // it does nothing, this is just an example ); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); Exception _exception = null; try { // before beginning a transaction we need to open the connection _con.Open(); // beginning transaction _con.Transaction.Begin(); // performing some operations on database _con.Execute_SQLQuery( "delete from \"CRD_User\" where \"IDUser\" = -1" // it does nothing, this is just an example ); // commit transaction _con.Transaction.Commit(); } catch (Exception _ex) { // rollback transaction _con.Transaction.Rollback(); _exception = _ex; } finally { //// terminate transaction //if (_con.Transaction.InTransaction) { // _con.Transaction.Terminate(); //} //// closing connection //if (_con.IsOpen) { // _con.Close(); //} // no need to (conditionally) terminate transaction and close connection, // simply disposing connection will do all that _con.Dispose(); _con = null; } if (_exception != null) { throw _exception; } //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }