473,801 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# - Displaying a progressbar while executing an SQL Query.

23 New Member
Hi ,

I would like a progress bar to be displayed while running an sql query. the progress bar doesn't have to move according to the query pace - I just want it to move back and forth while the query is executing , and to disappear when the query is completed.

My problem is that the progress bar does not appear when the query is running (I'm using the data adapter fill method in order to run my queries). What can I do ?

Thanks in advance.
Oct 19 '07 #1
12 35082
Plater
7,872 Recognized Expert Expert
You just want something like "Loading... " (or "Saving..." ) or something?

Create a label, and tell it to be "on top" of the other controls. Then set it to invisible.
Before you run your query, set it to "visible" and do a like .Update() on the control (to make sure it updates your UI before you start the query)
Then you can run your query.
When it's done, just set the label object back to invisible
Oct 19 '07 #2
yoavyoavyoav
23 New Member
Thanks. Actually the call to the "Update" method was what I was missing. why is it required by the way ?

Thanks again.
Oct 19 '07 #3
Plater
7,872 Recognized Expert Expert
I don't have an authoritative answer to it. But, just that the "normal" GUI calls of updating don't happen when your thread is busy doing something (like executing a big sql statement). So by using the .Update() you force a "one last redraw" to happen before it becomes tied up doing other stuff.
Oct 19 '07 #4
yoavyoavyoav
23 New Member
Hi ,

Using the Update did make it appear -but during the query execution it remains static. how can I cause it to change while the query is running (I just want it to move according to my set of instruction - for eg. back and forth). ?

Thanks.
Oct 26 '07 #5
Plater
7,872 Recognized Expert Expert
Make it happen in it's own thread.
Oct 26 '07 #6
yoavyoavyoav
23 New Member
I didn't find direct instructions on how to use threading (never used it before).
All I want is to open a new thread in which the progressbar will move back and forth (I have the logic for that so that's not the issue) - and when the query is completed I want the progressbar to disappear.

I've read about Invoke , etc etc , but didn't find something that worked well.
What should I do ? thx.
Oct 29 '07 #7
Plater
7,872 Recognized Expert Expert
If you have a function that handles the moving of the "loading... " stuff, when you submit your query just create a new thread and tell it to run that function. Then when your query returns, kill that thread and set the loading screen to invisible again.
Oct 29 '07 #8
yoavyoavyoav
23 New Member
OK...so I think that doesn't really work.
I've decided to put my query running in another thread - and I want the progressbar to run while the query is running. How do I know when the query has stopped running if it's in another thread (meaning, is there some sort of a "wait for thread to finish" function ? )
Oct 29 '07 #9
Plater
7,872 Recognized Expert Expert
myThread.Join() will block the current thread until the other thread completes.
Where mythread is the Thread object for your other thread.
Oct 29 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

15
6864
by: dixie | last post by:
I have a command to open the Access Options dialogue from code: DoCmd.RunCommand acCmdOptions It also opens the Database Window behind it. Is it possible to open the Options without having the database window open as well? dixie
8
19634
by: needin4mation | last post by:
Please consider: foreach (ListViewItem item in listViewFiles.Items) { // Display the ProgressBar control. pBar1.Visible = true; // Set Minimum to 1 to represent the first file being copied. pBar1.Minimum = 1; // Set Maximum to the total number of files to copy. pBar1.Maximum = 4; //filenames.Length;
1
5428
by: Mehr H | last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar in my webform (aspx) file. I have tried putting a Windows.Forms.ProgressBar as public on a regular winform designer form (form called ProgressForm) and the built the dll. Then I reference this new assembly from within my asp.net applicaiton and tried to access Windows.Forms.ProgressBar from within the ProgressForm but apparently it doesn't work. Because it won't...
3
4796
by: Mitchell Vincent | last post by:
In other programming languages I've been able to easily change the style of a progress bar between smooth and blocked. I find that is either really hidden or impossible in .NET. Am I missing something? I'm shocked that .NET doesn't have a style property for the progressbar control! -- - Mitchell Vincent - kBilling - An easy and affordable billing solution
1
696
by: nobody | last post by:
Hi I'm currently developing a Windows application. At the start of the application I load several tables into datatables in a dataset. I also use a progressbar to show the user how much percent of the total is already loaded. But I do this in a dirty way: I increment the progressbar with the same number after each table, but not all tables contain the same amount of data. I solved this with starting an other thread to increment the...
2
11129
by: =?Utf-8?B?QWFyb24=?= | last post by:
Since some controls such as the DataGridView take a long time to update themselves when performing certain tasks, I have added a StatusStrip with a ProgressBar on it. While I am updating the controls on the form, I want the ProgressBar to scroll in marquee mode. However, I cannot seem to get this to work. I set the StatusStripLabel to the text I want such as "Updating data..." and then set the ProgressBar's Style property to Marquee...
4
2513
by: sivamoorthy | last post by:
how to use a progressbar in a one cpp file but defined in another header file. the function in which i am using is a static member function. how to use the progressbar inside the function code: file name : flash.cpp void CFlasher::OnStartDownload (void *pDublicate) { bValueRet = DeviceIoControl (hHandle, \ (DWORD) IOCTL_SCUSBDFU_DETACH, NULL, \
6
10708
by: JB | last post by:
Hi All, I have a Windows Form application that shows a "please wait" form while I query a database for various information. I display my form using Show, then run my DB query, then Close the form at the end. To make it look even nicer I placed a marquee style Progress Bar on my form. It works exactly the same way, but the marquee style progress bar
10
10227
by: hsegoy1979 | last post by:
dear all iam new to sql server. I have a query. I want to display records in a new line. Iam using char(13) but it won't work. The table record contains only one field Name select * from record
0
9556
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,...
0
10516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10292
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10052
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
9101
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
7589
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
6829
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();...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
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

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.