4
Answers

Slow Datatable.Rows.Add()

kendalgoodrich

kendalgoodrich

20y
6.5k
1
Quick question everyone, I have an application in which I am accessing a MySql Database. Everything is fine except for when I try to add some lines to a DataTable. The very first Row I Add takes 6-7 seconds, after that I never have that problem again until I restart the application. Following is a snippet of code where the problem occurs: [code] dsDoctorList.Clear(); DataTable dtDocAppts = dsDoctorList.Tables["DoctorAppts"]; DataTable dtDocs = docSql.PullDocs(); //Load Doctor Number and Name foreach(DataRow dr in dtDocs.Rows) { DataRow myRow = dtDocAppts.NewRow(); myRow["doctor"] = dr["doctor"]; myRow["name"] = dr["name"]; //Right here is where it takes so long on the first add dtDocAppts.Rows.Add(myRow); } [/code] Does anyone have any suggestions as to what is causing this. Thanks, Kendal

Answers (4)