472,348 Members | 1,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

Datagridview refresh issue

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
1 3054
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: thomasp | last post by:
This is a two part question, 1) The code below should display a form with a datagridview and a few command buttons. This form should allow the...
6
by: George | last post by:
Hi, I have been encountering a refresh problem with DataGridView, which is bound to a DataTable. When I make updates (Add, Delete, update) to...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a...
3
by: David Cartwright | last post by:
Hi all, I'm having a weird time with a call to the Refresh() method of a DataGridView. I have a VB.NET 2005 Windows application with a main form...
4
by: shibeta | last post by:
Hello, I have problem with DataGridView and BindingSource. I have created DataSet and added TableData to it with manualy created columns (without...
1
by: romerve | last post by:
Hello; i am having some problems trying to get a form that has a datagridview to refresh after a new record is created. I have a MDI container...
2
by: RodneyAnonymous | last post by:
I'm trying to add multi-thread capabilities to a program I am writing so the users aren't locked into loading a potentially large log file without...
2
by: YouPoP | last post by:
Hi, I have a Window Form to which i added a datagridview. The binding source is working well, but does not update if the database is modified...
5
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to be able to increase or decrease row heights of a populated DataGridView from the keyboard. I set up a test program with menu items to...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.