用事务一次处理多条SQL语句
时间:2010-10-31 来源:Trible.H
前台调用:
try
{
//1.查出会员余额
decimal usermoney = SqlDal.EntityUserinfo.GetModel(int.Parse(cookieUserID)).Money;
//2.修改余额
decimal Zmoney = usermoney + moAD.Commission;
//写SQL语句
List<string> SQLStringList = new List<string>();
string clickSql = "insert into [user] (name,age)values('" + 小名 + "','“+4岁+”')";
string userSql = "update [class] set [name]='" + 幼儿园 + "' where id=" + 2 + " ";
SQLStringList.Add(clickSql);
SQLStringList.Add(userSql);
SqlDal.SqlHelper.ExecuteSqlTran(SQLStringList);
//数据库操作成功
//提示
CommonClass.Xmls xmls1 = new CommonClass.Xmls();
string path1 = CommonClass.Unit.GetMapPath(@"/Admin/Configs/SysSettingInfo.config");
string ClickTishi = xmls1.GetXmlNode(path1, "SysSettingInfo/ClickTishi");
//替换字符
ClickTishi = ClickTishi.Replace("[$]", moAD.Commission.ToString("0.00"));
context.Response.Write(ClickTishi); //输出
}
catch (Exception ex)
{
//Response.Write(ex.Message);
context.Response.Write("操作失败!" + ex.Message); //输出
}