Hi
i have a big(large) database.
when i want to open it,my program take long to open it.
.
how can i use trackbar to show this delay?
- What database server?
- How "big" is your database? You know big is relative.
About your "long open";
1- Are you trying to open connection to database which is long?
2- Are you trying to open an SQL statement (a table or a query) which is long?
2a- How many records are there in table(s) you read from?
2b- How many records you fetch out of that total record count in your table(s) (if your user prefer to see them all)
2c- Even if you change filtering parameters in your SQL statement, do you need to close and open your SQL more than once in your application?
Above questions are relevant in a way that it maybe possible that you can do some improvement in your database/table to make it open faster.
Assuming you are running an SQL statement taking long to execute:
As far as I know it is not quite possible to display a "progress bar" kind of thing when opening an SQL statement automatically. There is a command sent to database server and a reply received most of the time. No information exchange in between. I am not aware of advanced servers like ORACLE. They may have some solutions.
Anyway, you may "guess" how long it takes to run your SQL and fake users as if it is making a progress (running and not stuck). You can do so by using a thread (worker thread I will call it) to execute your query. While query is executed in a worker thread, update your user interface like each second and make a progress of 5% or some number more suitable to your use. Once worker thread completed, display results immediately. You do not need to make progress wait up to 100%.
Unfortunately, I am no thread expert at all. So, I will not be able to help you writing some sample code. All I know is that such an approach may convince your user that query is running and he/she should wait while progress bar is advancing.