软件搜索:
网站首页 会员中心 软件供求 投资合作 软件企业名录 软件市场 免费软件
 
 
首页> 软件项目交易网Www.xAspx.Com> 技术文档内容
ADO.NET json数组多条记录执行在DAL层循环(执行存储过程)

 
    public int UpdateRegdate(tj_book_patient regdatejson)
{
int temp;
SqlParameter[] ps = new SqlParameter[]{

//实体类的字段和存储过程的参数对齐

new SqlParameter("@reg_date",regdatejson.reg_date),
new SqlParameter("@pat_code",regdatejson.pat_code),
new SqlParameter("@reg_time",regdatejson.reg_time),
new SqlParameter("@hsp_code",regdatejson.hsp_code),

//存储过程中的output参数
new SqlParameter("@reg_no",'' ''),
};

//执行存储过程
temp = SqlHelper.ExecuteNonQuery("pr_update_dlyyregdate", ps);
return temp;
}

//此处调用上面的方法

public int InsertRegister(string regdatejson) {

//反序列化json数组

JavaScriptSerializer js = new JavaScriptSerializer();


List<tj_book_patient> pt = js.Deserialize<List<tj_book_patient>>(regdatejson);
int result = 0;
foreach (tj_book_patient s in pt)
{
result = UpdateRegdate(s);

//存储过程返回的output参数来判断数据是否执行成功

switch (result)
{
case 0: message = "添加失败"; break;
case 1: message = "添加成功"; break;
}


}
return result;
}
 
 
 
  Copyright © 2025,By Www.xAspx.Com(软件项目交易网),All Rights Reserved.