470,591 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Loading a Datagridview taking a long time...sometimes


I have a simple Windows Form, where i have a datagridview. The user can
switch between databases and select the tables via DropDownLists. I am
having a problem that I can't really pinpoint when it happens but
occassionally tables take a long time to load... They are not the same
tables, and it doesn't appear consistent. But a simple table that contains
a single row can take up to 30 seconds to load, while only seconds before a
table with 4000+ rows loaded in less than a second.

The following code snippet is where the problem appears to be occurring. If
I pause the application while it is occurring it always is on the
da.Fill(dt) line.

dt = the dataTable



String connectionString = "Data Source=" + strCurSQLServer+ "; Integrated
Security=SSPI; Initial Catalog=master";

SqlConnection cnSQL = new SqlConnection(connectionString);

dataGridView1.DataSource = bindingSource1;

da.SelectCommand = new SqlCommand(selectCommand, cnSQL);

SqlCommandBuilder builder = new SqlCommandBuilder(da);

dataGridView1.DataSource = bindingSource1;

lblStatus.Text = "Loading Data...";



lblRecordCount.Text = "Returned " + strSQLTable + " - " +
dt.Rows.Count.ToString() + " rows";

bindingSource1.DataSource = dt;

dataGridView1.Columns[0].ReadOnly = true;


I have also had the Error "Object Reference not set to an instance of an
object" error in the compiled version, but I can't reproduce it in Debug

I know this is kind of vague, but can anyone offer a few ideas where to look
in solving this?


Mar 1 '06 #1
0 1470

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Aguilar, James | last post: by
5 posts views Thread by Kurt Bauer | last post: by
1 post views Thread by Sunny | last post: by
5 posts views Thread by John Richardson | last post: by
5 posts views Thread by =?Utf-8?B?V2FubmFiZQ==?= | last post: by
6 posts views Thread by Gouri.Mahajan7 | last post: by
6 posts views Thread by Miro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.