473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Loading a Datagridview taking a long time...sometimes

RSH

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

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

Application.DoEvents();

da.Fill(dt);

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

bindingSource1.DataSource = dt;

dataGridView1.Columns[0].ReadOnly = true;

Application.DoEvents();

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
mode.

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

Thanks,

Ron
Mar 1 '06 #1
0 1675

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matthew | last post by:
I am not the most talented programmer to grace the earth by a long shot. But I've got a gripe I need to air about the .NET implementaion of Visual Basic. I can live with alot of the major changes...
17
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. ...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
1
by: Sunny | last post by:
Hi, I am using Databases in my applications, i have a table with an average of 3.5 million records, i am trying to show the search results in a DataGrid from that table, but the results take a very...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
2
by: Steve | last post by:
Hi- OK, I've got a DataGridView, I've created a BindingSource from one of my Business Entity object (based on generated classes from EntitySpaces) I've left the default column setup so that all...
5
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
We have a page that is loading very slow. There is not a lot of data, not a lot of users are connected at the same time and the page does not produce an error, so I am not sure where to start to...
6
by: Gouri.Mahajan7 | last post by:
Hello, When I press the button on the web page I am loading the user control on the web page. This user control is invoking some methods of the web service. The control on the web page is loaded...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.