ADO. NET json array multiple records are executed in the DAL layer loop (execution of Stored Procedures), jsondal

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.