本文介绍了OLEDB更新性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我遇到大麻烦请帮帮我...

在我的应用程序中,我有一个862行的Datagridview,我使用MDB作为我的数据库。我需要根据我在下面的代码中使用的Datagridview更新我的数据库值。但它需要花费太多时间才能完成。请帮我加快这个过程..

Hi,
I am in big trouble please help me...
In my application I have a Datagridview with 862 rows and I am using MDB as my database. I need to update my database values according to my Datagridview for that I used below code. But its taking too much time to complete. Please help me to speed up the process..

string _ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
           "Data Source=" + DSource + ";" +
           "Jet OLEDB:Engine Type=5";
pg.Maximum = DrawingList.Rows.Count;
pg.Value = 0;
OleDbCommand cmd = new OleDbCommand();
OleDbConnection con = new OleDbConnection(_ConnectionString);
cmd.Connection = con;
con.Open();
foreach (DataGridViewRow row in DrawingList.Rows)
{
    pg.Increment(1);
    cmd.CommandText = "update " + LbJobId.Text + " set  title = ? , created_on = ? , added_on = ? , edited_by = ? , edited_on = ? , checked_by = ? , checked_on = ? , back_dftd_by = ? , back_dftd_on = ? , cc_by = ? , cc_on = ? , cc_crrctn_by = ? , cc_crrctn_on = ? , qc_by = ? , qc_on = ? , qc_crrctn_by = ? , qc_crrctn_on = ? , remarks = ? , last_updated_by = ? , last_updated_on = ?   where drawing= ? ;";
    cmd.Parameters.AddWithValue("@title", row.Cells[3].Value.ToString());
    cmd.Parameters.AddWithValue("@created_on", row.Cells[4].Value.ToString());
    cmd.Parameters.AddWithValue("@added_on", row.Cells[5].Value.ToString());
    cmd.Parameters.AddWithValue("@edited_by", row.Cells[6].Value.ToString());
    cmd.Parameters.AddWithValue("@edited_on", row.Cells[7].Value.ToString());
    cmd.Parameters.AddWithValue("@checked_by", row.Cells[8].Value.ToString());
    cmd.Parameters.AddWithValue("@checked_on", row.Cells[9].Value.ToString());
    cmd.Parameters.AddWithValue("@back_dftd_by", row.Cells[10].Value.ToString());
    cmd.Parameters.AddWithValue("@back_dftd_on", row.Cells[11].Value.ToString());
    cmd.Parameters.AddWithValue("@cc_by", row.Cells[12].Value.ToString());
    cmd.Parameters.AddWithValue("@cc_on", row.Cells[13].Value.ToString());
    cmd.Parameters.AddWithValue("@cc_crrctn_by", row.Cells[14].Value.ToString());
    cmd.Parameters.AddWithValue("@cc_crrctn_on", row.Cells[15].Value.ToString());
    cmd.Parameters.AddWithValue("@qc_by", row.Cells[16].Value.ToString());
    cmd.Parameters.AddWithValue("@qc_on", row.Cells[17].Value.ToString());
    cmd.Parameters.AddWithValue("@qc_crrctn_by", row.Cells[18].Value.ToString());
    cmd.Parameters.AddWithValue("@qc_crrctn_on", row.Cells[19].Value.ToString());
    cmd.Parameters.AddWithValue("@remarks", row.Cells[20].Value.ToString());
    cmd.Parameters.AddWithValue("@last_updated_by", row.Cells[21].Value.ToString());
    cmd.Parameters.AddWithValue("@last_updated_on", row.Cells[22].Value.ToString());
    cmd.Parameters.AddWithValue("@drawing", row.Cells[2].Value.ToString());
    cmd.ExecuteNonQuery();

}
con.Close();



先谢谢。


Thanks in Advance.

推荐答案

cmd.Parameters.Clear();
  cmd.CommandType = CommandType.Text;


这篇关于OLEDB更新性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:00