Esempio n. 1
0
        /// <summary>
        /// Hows to use.
        /// </summary>
        public void HowToUse()
        {
            DB.DAL.Base.Connection myConnection = null;
            SqlTransaction         transaction  = null;

            try
            {
                myConnection = new DB.DAL.Base.Connection();
                myConnection.Open();
                var connection = (SqlConnection)myConnection.DbConnection;

                transaction = connection.BeginTransaction();

                /*Database Operation using one connection*/

                transaction.Commit();
            }
            catch (Exception ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                Logger.Error(ex);
            }
            finally
            {
                if (myConnection != null)
                {
                    myConnection.Dispose();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Hows to use.
        /// </summary>
        public void HowToUse()
        {
            DB.DAL.Base.Connection myConnection = null;

            try
            {
                myConnection = new DB.DAL.Base.Connection();
                myConnection.Open();
                var connection = (SqlConnection)myConnection.DbConnection;

                /*Database Operation using one connection*/
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            finally
            {
                if (myConnection != null)
                {
                    myConnection.Dispose();
                }
            }
        }