By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

Datagridview refresh issue

P: n/a
RSH
Hi,

I have a situation where I have a DDL that lists all of the tables in a
particular database, and a Datagridview which appears in the same from below
the DDL.. When the user selects a new database table from the list I
refresh the datagridview with the newly selected tables data.

This works fine but after a few tables have been selected it takes a very
long time to load some of the tables. Some tables that contain only one row
of information take longer to load than a table that has 2000 records. It
isn't consistent as far as I can tell either. I have even had a couple
users complain of a "Object Required" error which I have been able to
reproduce in the compile but not stepping through code.

This seems like I am not clearing something out properly, or something is
hanging. When it hangs in code it is always at the same line: da.Fill(dt);

Here is the snippet of code:
dt.Clear();

Application.DoEvents();

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 = "";

Application.DoEvents();

da.Fill(dt);

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

bindingSource1.DataSource = dt;

dataGridView1.Columns[0].ReadOnly = true;

Application.DoEvents();
Is there anything I can check or clean up to make this more responsive?

Thanks!
Ron
Mar 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
RSH
Is there any more information I can provide to get some help here?

Thanks,
Ron

"RSH" <wa*************@yahoo.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a situation where I have a DDL that lists all of the tables in a
particular database, and a Datagridview which appears in the same from
below the DDL.. When the user selects a new database table from the list
I refresh the datagridview with the newly selected tables data.

This works fine but after a few tables have been selected it takes a very
long time to load some of the tables. Some tables that contain only one
row of information take longer to load than a table that has 2000 records.
It isn't consistent as far as I can tell either. I have even had a couple
users complain of a "Object Required" error which I have been able to
reproduce in the compile but not stepping through code.

This seems like I am not clearing something out properly, or something is
hanging. When it hangs in code it is always at the same line:
da.Fill(dt);

Here is the snippet of code:
dt.Clear();

Application.DoEvents();

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 = "";

Application.DoEvents();

da.Fill(dt);

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

bindingSource1.DataSource = dt;

dataGridView1.Columns[0].ReadOnly = true;

Application.DoEvents();
Is there anything I can check or clean up to make this more responsive?

Thanks!
Ron

Mar 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.