Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Refresh Query

Posted on 1997-11-23
7
Medium Priority
?
331 Views
Last Modified: 2010-04-04
Now I asked this one before,but maybe now someone comes up with another answer. I have a Query on a DBGrid,but it won't refresh after I updated one of its sourcefiles. I have RequestLive set to true. I've refreshed everything I can,but nothing helps. Query.Close followed by Query.Open takes too much time. Is there anything else I can try?
To explain what is going on: I have a query on a grid;the SQL statement involves an 'order by' statement which puts 'CanModify' to False. Since the user must be allowed to set a checkbox to false or true by clicking on it on the grid,I have the table to be updated linked to the query (by setting the table-mastersource to the query),so, by clicking, I update the table and then refresh the query. But ,as stated,the query JUST WON'T refresh (unless I close and open it which is a loosy way to refresh).
In case it is not clear what I mean :

 Query ,involving Table1, linked to Table1 (<-MasterSource = Query)
 
 DBGrid showing Query
 User Clicks DBGrid -> Table1 is updated.
 Refresh Query -> User sees new value(which doesn't work)

 PS I have only 45 points left,if I had more I would give a 100 to solve this one!
0
Comment
Question by:lizzzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 80 total points
ID: 1351536
Your ORDER BY clause also sets the RequestLive property to False. This means that you simply _cannot_ refresh the table (look for Refresh Method into the Delphi Help file).

-julio
0
 

Author Comment

by:lizzzard
ID: 1351537
Does anyone have a suggestion then how to solve this problem? I cannot use a table,because I HAVE to filter the records using the SQL IN statement. Can I for example force a query to use a certain index without using an ORDER BY statement?
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1351538
First, if you need more suggestions, just wait to accept an answer; now your question is open to me only (other experts should pay each time they would access the question).

Back to the question:

i haven't seen your SQL statement, but i guess you can just go with the Filter property of a TTable to do what your IN SQL clause does, and keep your records ordered with an index.

If this does not apply, please show your SQL statement.


-julio
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lizzzard
ID: 1351539
Well, I could do it with a filter,but it could turn out to be a gigantic one. The SQL statement is variable and put together once the user has made his/her choices what he/she wishes to see,and in what order.
It could turn out like this
Select * from MTG where Color in ("B","U","G","W","Art") and Edition in ("A","B","WL","CH","TP","RV","VI") order by Color,Card,Edition;

I suppose I could write a filter for this one.....
0
 

Author Comment

by:lizzzard
ID: 1351540
I do have an additional question/comment:
I could go for the query.close/query.open solution. It takes a little longer for the result to show up,but I think I can get away with it,if there is a possibility of setting sort=OFF to enable RequestLive.
I managed to get the good positioning with GotoBookmark after the query.open,but sometimes the row shows up on a different position in the grid. If I can fix this I'm out of trouble! Do you happen to know how I can a specific row to show up on the position it was before the query.close?
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1351541
> The SQL statement is variable

well, i would have seen it.
And, are you calling the Prepare method for your dynamic query? that makes a query open much much faster.

This said, consider that your main problem is that you need to order the result set on more than one field.

I can see just a few solutions:

1. you forgot to call Prepare, and just have to do that;

2. you are working on dbase tables and can create one or more expression indexes to order the table with; than, each time a user submits a request, you create a filter expression on the fly, and open the right index to order the result set.

3. you give a non-live result set to the user (he/she just need to be able to switch a check box), and keep synchronized and updated the underlying table.

4. similar to 3rd; you give a non-live result set and, when the user has *finished*, you do an update of the underlying table.

Ok, let me know.

-julio

BTW, another reason for not grading too soon an answer is that, sometimes, you find out you should have given more than Cx45 points.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1351542
> Do you happen to know how I can a specific row to show up on the position it was before the query.close?

AFAIK, you cannot.
This is because you cannot trust a Bookmark after the data set has been closed - a Bookmark is a reference to an internal BDE table, not a reference to a fisical row.

IMO, giving the user a non-live result set could be the best strategy.

-julio
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question