当前位置: 首页>>代码示例>>C#>>正文


C# NpgsqlTransaction.Commit方法代码示例

本文整理汇总了C#中Npgsql.NpgsqlTransaction.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlTransaction.Commit方法的具体用法?C# NpgsqlTransaction.Commit怎么用?C# NpgsqlTransaction.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Npgsql.NpgsqlTransaction的用法示例。


在下文中一共展示了NpgsqlTransaction.Commit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getData

 /// <summary>
 /// Lấy dữ liệu từ câu lệnh chứa trong thuộc tính Command
 /// </summary>
 /// <returns></returns>
 private DataSet getData() //Get data with SQLcommand
 {
     Connect();
     trans = conn.BeginTransaction();
     DataSet ds = new DataSet();
     cmd.Connection = conn;
     cmd.CommandText = Command;
     cmd.CommandType = Commandtype;
     cmd.Transaction = trans;
     NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(cmd);
     try
     {
         adapter.Fill(ds);
         trans.Commit();
         Disconnect();
         return ds;
     }
     catch (NpgsqlException ex)
     {
         Error = ex.Message;
         trans.Rollback();
     }
     return null;
 }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:28,代码来源:DataProvider.cs

示例2: executeScalar

 /// <summary>
 /// thực thi SQL, thường dùng cho các dòng lệnh MAX,AVG,COUNT,.....
 /// </summary>
 /// <returns>Object</returns>
 private object executeScalar()// Execute a command return only 1 value
 {
     Connect();
     trans = conn.BeginTransaction();
     cmd.CommandText = Command;
     cmd.CommandType = Commandtype;
     cmd.Transaction = trans;
     cmd.Connection = conn;
     object obj = null;
     try
     {
         obj = cmd.ExecuteScalar();
         trans.Commit();
     }
     catch (NpgsqlException ex)
     {
         trans.Rollback();
         if (ex.Code == "23505")
         {
             if(ex.BaseMessage.Contains("quyet_dinh"))
                 throw new Exception("Mã quyết định đã tồn tại, xin vui lòng kiểm tra lại.");
             else if(ex.BaseMessage.Contains("ma_nv"))
                 throw new Exception("Mã nhân viên đã tồn tại, xin vui lòng kiểm tra lại.");
         }
         throw new Exception(ex.Message);
         
     }
     Disconnect();
     return obj;
 }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:34,代码来源:DataProvider.cs

示例3: getDataReader

        /// <summary>
        /// Lấy Dữ Liệu Từng Dòng
        /// </summary>
        /// <returns>IDataReader</returns>
        private IDataReader getDataReader() // Đọc dữ liệu dạng Datareader
        {
            Connect();
            trans = conn.BeginTransaction();
            NpgsqlDataReader datard = null;
            try
            {
                cmd.CommandText = Command;
                cmd.CommandType = Commandtype;
                cmd.Transaction = trans;
                datard = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                trans.Commit();
            }
            catch (NpgsqlException ex)
            {
                Error = ex.Message;
                trans.Rollback();

            }
            // Disconnect();
            return datard;
        }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:26,代码来源:DataProvider.cs

示例4: executeNonQuery

        /// <summary>
        /// Thực Thi các câu lệnh SQL (thường là UPDATE)
        /// </summary>
        /// <returns>giá trị các dòng có ảnh hưởng</returns>
        private int executeNonQuery()// Execute a command without return
        {
            Connect();
            trans = conn.BeginTransaction();
            cmd.CommandText = Command;
            cmd.CommandType = Commandtype;
            cmd.Connection = conn;
            cmd.Transaction = trans;
            int rowEffect = 0;
            try
            {
                rowEffect = cmd.ExecuteNonQuery();

                trans.Commit();
            }
            catch (NpgsqlException ex)
            {
                Error = ex.Message;
                trans.Rollback();
            }
            Disconnect();
            return rowEffect;
        }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:27,代码来源:DataProvider.cs

示例5: ReleaseTransaction

 public static void ReleaseTransaction(ref NpgsqlTransaction pPgsTrans)
 {
     try
     {
         pPgsTrans.Commit();
         pPgsTrans.Dispose();
         pPgsTrans = null;
         GC.Collect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "ReleaseTransaction");
     }
 }
开发者ID:wzhangRieker,项目名称:PostGIS,代码行数:14,代码来源:GlobalClass.cs


注:本文中的Npgsql.NpgsqlTransaction.Commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。