JSP_c# 执行事务函数代码,复制代码 代码如下:/// summar
复制代码 代码如下: /// summary /// 执行多条sql语句,实现事务 /// /summary /// param多条sql语句/param public int ExecutrSqlTran(System.Collections.ArrayList arraySql) { int itemnum; DbOpen(); SqlCommand cm = new SqlCommand(); cm.Connection = scn; SqlTransaction tx = scn.BeginTransaction(); cm.Transaction = tx; try { for (int i = 0; i arraySql.Count; i++) { string strSql = arraySql[i].ToString(); if (strSql.Trim().Length 1) { cm.CommandText = strSql; cm.ExecuteNonQuery(); } } tx.Commit(); itemnum = 1; } catch (SqlException E) { tx.Rollback(); itemnum = 0; throw new Exception(E.Message); } DbClose(); return itemnum; } } ,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/jsp/11827.shtml
