Dear All,
I want to upload huge amount of data from gridview to database but fast way i already did in below code but its taking time like 300 rows data taking 5 to 6 mints. please need your supports how can i upload fastest to database from girdivew using c#.
below are my codes which i am using i used for loop and foreach both are same taking times.
cs.query = @"insert into Table (Account,Currency,Posted,Posted_Hijrah,Value_date,Value_date_Hijrah, Debit_amount,Credit_amount,Running_balance,Reference,Description,Narrative_1,Narrative_2,Narrative_3,Narrative_4,created_date, created_by,status) Values (@Account,@Currency,@Posted,@Posted_Hijrah,@Value_date,@Value_date_Hijrah, @Debit_amount,@Credit_amount,@Running_balance,@Reference,@Description,@Narrative_1,@Narrative_2,@Narrative_3,@Narrative_4,@created_date, @created_by,@status)"; cs.cmd = new SqlCommand(cs.query, cs.conn); cs.cmd.Parameters.AddWithValue("@Account", row.Cells[0].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Currency", row.Cells[1].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Posted", row.Cells[2].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Posted_Hijrah", row.Cells[3].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Value_date", row.Cells[4].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Value_date_Hijrah", row.Cells[5].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Debit_amount", row.Cells[6].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Credit_amount", row.Cells[7].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Running_balance", row.Cells[8].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Reference", row.Cells[9].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Description", row.Cells[10].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Narrative_1", row.Cells[11].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Narrative_2", row.Cells[12].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Narrative_3", row.Cells[13].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@Narrative_4", row.Cells[14].Value.ToString().Trim());
cs.cmd.Parameters.AddWithValue("@created_date", System.DateTime.Now.ToString("dd-MMM-yyyy"));
cs.cmd.Parameters.AddWithValue("@created_by", System.Net.Dns.GetHostName());
cs.cmd.Parameters.AddWithValue("@status", "Yes");
cs.cmd.ExecuteNonQuery();