I know DataAdapters have performance issues, but are there any ways around it that might be faster? At the moment, the DataAdapter.Fill method is taking 5-6 seconds on 3000 records, which is too slow for my app. If I remove the Fill
line and just execute the SQL (using SQLCE), it takes 20 milliseconds, so I'm guessing the query isn't the problem. I've tried adding BeginLoadData
on the datatable, but it makes no difference to the performance.
using (SqlCeConnection con = new SqlCeConnection(conString))
{
con.Open();
using (SqlCeDataAdapter dAdapter= new SqlCeDataAdapter())
{
using (SqlCeCommand com = new SqlCeCommand(query, con))
{
com.Parameters.Add("uname", textBox1.Text);
dAdapter.SelectCommand = com;
dAdapter.SelectCommand.Connection = con;
DataTable dTable = new DataTable();
dAdapter.Fill(dTable);
dataGridView1.DataSource = dTable;
}
}
}
Are there better ways to fill a DataGridView or speed up the Fill
method?