473,700 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DoE vents();

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

SqlConnection cnSQL = new SqlConnection(c onnectionString );

dataGridView1.D ataSource = bindingSource1;

da.SelectComman d = new SqlCommand(sele ctCommand, cnSQL);

SqlCommandBuild er builder = new SqlCommandBuild er(da);

dataGridView1.D ataSource = bindingSource1;

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

lblRecordCount. Text = "";

Application.DoE vents();

da.Fill(dt);

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

bindingSource1. DataSource = dt;

dataGridView1.C olumns[0].ReadOnly = true;

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

Thanks!
Ron
Mar 6 '06 #1
1 3144
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******** ******@TK2MSFTN GP15.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.DoE vents();

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

SqlConnection cnSQL = new SqlConnection(c onnectionString );

dataGridView1.D ataSource = bindingSource1;

da.SelectComman d = new SqlCommand(sele ctCommand, cnSQL);

SqlCommandBuild er builder = new SqlCommandBuild er(da);

dataGridView1.D ataSource = bindingSource1;

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

lblRecordCount. Text = "";

Application.DoE vents();

da.Fill(dt);

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

bindingSource1. DataSource = dt;

dataGridView1.C olumns[0].ReadOnly = true;

Application.DoE vents();
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
9675
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 user to make change to the records displayed in the datagridview and have to changes written to the Filters table in an MS Access database. The if the user chooses, clicking on the Restore button empties the contents of the Filters table, refills it with the contents of the DefaulFilters...
6
50458
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 the DataGridView, everything flow nicely to DataTable. No problem here. However, when I add data (programatically) to the DataTable, the DataGridView does not refresh right away. If I minimize and show my form,
2
8715
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 table in the dataset. At the same time, I've added checkbox columns that are not bounded the table. This datagridview is located in the tab (2nd). I thought I mention that since that might be part of the problem (?). When the applications start, it will need some parameter criteria selection...
3
7564
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 and a "worker" thread. The main form delegates a Sub to the worker so that the latter can refresh the DataGrid after updating the DataTable driving it. When I run the app under the debugger, everything's fine. But when I run it for real, it hangs, apparently in the Refresh() method of the...
4
18708
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 DataAdapter - I'm not using MSSQL). On the Form I put DataGridView and BindingSource, and connected them (BindingSource of course is also connected with DataSet). Next on the separated thread I'm reading data from DB and load them do DataSet (more preciselly, readed data I've saved as XML and...
1
5013
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 and menu form and add new record form; the menu form display the data using a data grid view and the add record form creates an object and passes that data to a class method which creates the record using sqlcommand. The add new record form is loaded after the user clicks on the add button on...
2
4499
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 being able to use the program for anything else. Everything is running smoothly, except that when the new thread finishes, the scrollbar for my DataGridView is horrendously broken. It appears as fragments of other parts of the interface, or not at all, and cannot be clicked on to scroll. Here's a...
2
5521
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 outside the application (i mean not showing the modification made to the database). Trying to solve my problem, i added a timer to the form that Fill the datagridview every xx milliseconds (basically a timer that calls the Form_Load method). The timer is working nicely, but because it always refresh...
5
6682
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 increase and decrease, assigned shortkey keys (ctrl-UpArrow and ctrl-DnArrow), and attached handlers that execute this code: public partial class MainForm : Form { . . . dataGridView.RowTemplate.Height += increment; Refresh();
0
8721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8964
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8918
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7804
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5900
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2024
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.