C#存储过程加事务
来源:互联网 发布:oa工作流数据库设计 编辑:程序博客网 时间:2024/05/10 03:16
public DataSet GettPerformance(string AgentID, string StartDate, string EndDate)
{
try
{
Regex regex = new Regex(@"^\d+W");
DataSet datas = null;
int ID = 0;
if (AgentID != "" && AgentID != null)
{
if (!regex.IsMatch(AgentID))
{
ID = Convert.ToInt32(AgentID);
}
}
else
{
ID = 0;
}
SqlParameter[] param = new SqlParameter[]{new SqlParameter("@StartDate",StartDate),
new SqlParameter("@EndDate",EndDate),
new SqlParameter("@AgentID",ID)
};
// string strsql = "EXEC p_GetACDReport '" + StartDate + "','" + EndDate + "'," + ID;
datas = GetDataSet("p_GetACDReport", param);
return datas;
}
catch
{
return null;
}
}
public DataSet GetDataSet(string proName, params SqlParameter[] param)
{
DataSet ds = null;
SqlTransaction st = null;
try
{
string connString = ConfigurationManager.ConnectionStrings["WISEDEMO"].ConnectionString;
SqlConnection SqlConn = new SqlConnection(connString);
if (SqlConn == null)
{
SqlConn.Open();
}
if (SqlConn.State == ConnectionState.Closed)
{
SqlConn.Open();
}
if (SqlConn.State == ConnectionState.Broken)
{
SqlConn.Open();
}
st = SqlConn.BeginTransaction();
ds = new DataSet();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = SqlConn;
cmd.CommandText = proName;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
if (param != null)
{
cmd.Parameters.AddRange(param);
}
cmd.Transaction = st;
if (st != null)
{
cmd.ExecuteNonQuery();
st.Commit();
}
adapter.Fill(ds);
return ds;
}
catch
{
st.Rollback();
return null;
}
}
- C#存储过程加事务
- mysql 存储过程加事务的简单写法
- sql 中事务、C#中事务、存储过程返回值
- C#完整执行存储过程的代码加实例[转载]
- C#完整执行存储过程的代码加实例
- Mysql | 事务&存储过程
- 事务,触发器,存储过程
- 存储过程事务使用
- 存储过程与事务
- 存储过程事务
- Mysql | 事务&存储过程
- Sql 存储过程 事务
- hibernate 存储过程事务
- 存储过程 事务
- 事务和存储过程
- plsql 存储过程 事务
- 存储过程和事务
- 存储过程与事务
- js 清空数组
- 在ubuntu10.4虚拟机上通过rvm安装ruby on rails
- 代码测试 导入测试
- 2011最全的程序员薪资,经验,学历,跳槽分析
- 数据库索引及优化
- C#存储过程加事务
- 创建表空间语句 创建用户
- CComboBox设置下拉列表宽度与字符宽度适应
- 中小企业如何实施股权激励
- android 屏蔽某一目录下的图片资源 音乐或是图片库不显示指定数据夹
- js clone对象的三个方法
- PB数据窗口对象值获取
- 如何在ashx页面获取Session值
- ADO.NET连接数据库,及基本操作