ADO. NET json array multiple records are executed in the DAL layer loop (execution of Stored Procedures), jsondal
Public int UpdateRegdate (tj_book_patient regdatejson)
{
Int temp;
SqlParameter [] ps = new SqlParameter [] {
// Align object fields with stored procedure parameters
New SqlParameter ("@ reg_date", regdatejson. reg_date ),
New SqlParameter ("@ pat_code", regdatejson. pat_code ),
New SqlParameter ("@ reg_time", regdatejson. reg_time ),
New SqlParameter ("@ heat _ code", regdatejson. Heat _ code ),
// Output parameters in the Stored Procedure
New SqlParameter ("@ reg_no ",''),
};
// Execute the Stored Procedure
Temp = SqlHelper. ExecuteNonQuery ("pr_update_dlyyregdate", ps );
Return temp;
}
// Call the above method here
Public int InsertRegister (string regdatejson ){
// Deserialize the json Array
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 );
// The output parameter returned by the stored procedure to determine whether the data is successfully executed
Switch (result)
{
Case 0: message = "failed to add"; break;
Case 1: message = "added successfully"; break;
}
}
Return result;
}
Indicate the source for forwarding