Can yu give an example in web application where we use parallel processing for inserting and updating SQL database by C#.net simultaneously.
vasanth2vasu
Posts
-
parallel programming -
parallel programmingsupposing if there are 2 updates taking place simultaneously the updates takes some time.so to avoid the time delay i need to do it using parallel programming or threading. My main aim is to reduce the CPU work usage.
-
parallel programmingI have created a web application for inserting and updating a set of record using C#.net. the coding is as follows. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class insert : System.Web.UI.Page { SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\PRAVINR\Documents\Visual Studio 2010\WebSites\strikers\App_Data\royal.mdf;Integrated Security=True;User Instance=True"); protected void Page_Load(object sender, EventArgs e) { DataBind(); } protected void Button1_Click(object sender, EventArgs e) { try { con.Open(); SqlCommand cmd = new SqlCommand("insert rusty values(@CustID,@Name,@Address,@City,@Pin,@State,@Country,@ContactNO)", con); cmd.Parameters.AddWithValue("@CustID", TextBox1.Text); cmd.Parameters.AddWithValue("@Name", TextBox2.Text); cmd.Parameters.AddWithValue("@Address", TextBox3.Text); cmd.Parameters.AddWithValue("@City", TextBox4.Text); cmd.Parameters.AddWithValue("@Pin", TextBox5.Text); cmd.Parameters.AddWithValue("@State", TextBox6.Text); cmd.Parameters.AddWithValue("@Country", TextBox7.Text); cmd.Parameters.AddWithValue("@ContactNO", TextBox8.Text); cmd.ExecuteNonQuery(); Label1.Text = "Inserted Completed.."; } catch (Exception ex) { Label1.Text = ex.ToString(); } finally { con.Close(); } } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; TextBox8.Text = ""; } } i need to change the coding to parallel processing so that the process of inserting is done parallel. Can anyone help me solving this ?