Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 6 Jahren, 5 Monaten
Letzter Beitrag:
vor 6 Jahren, 5 Monaten
Beteiligte Autoren:
Piet van Zanten, Arie, Paulo Oliveira

Query not executing properly

Startbeitrag von Piet van Zanten am 26.01.2012 17:25

Hi,

I noticed a weird problem.
I'm using a query that is refreshed if the file version changes.
The query contains relatively static data, but the data is frequently used, so no need to execute every time it's needed.
For that reason I put the code in the focus loss of the main menu window.
I store the file versions in an associative array. Using HFCS.
IF aa_nVersion["myfile"]HVersion(myfile) THEN
WHILE NOT HExecuteQuery(qry_myfile,hQueryDefault)
IF NOT YesNo("Unable to execute query.",HErrorInfo(hErrMessage),"Try again?") THEN RESULT False
END
aa_nVersion["myfile"]=HVersion(myfile)
END
Now if the file myfile has been changed, returned to the mainmenu and open another window with a table based on this query, the table only shows about 10% of the query content. :confused:

Solution: if I put the code in the focus gain code of the mainmenu window all's fine.
My guess for the cause of this:
I use use(MyWindow) instead of open(MyWindow) to get rid of the underlying mainmenu. (If you move the active window to another position or another screen, the mainmenu still remains in place and cannot be moved).
Apparently the process to fill the query has not completed yet when the new window is initialized. Probably because of the "use" statement?

Regards,
Piet

Antworten:

It's probably because of the USE, it stops everything still running and opens the new window.

One possible work around, not tested:
read the query into one array of structures
cancel the query (one less file opened in the db engine)
use("yourwindow")
link the table to the array instead of the query.

von Paulo Oliveira - am 26.01.2012 18:13
Piet,
I can't tell you if the USE() statement is causing this behavior. It may very well be so.
I guess you tried some other ways of refreshing data, only when it is necessary.
But here is one of mine ;)

I too have a bunch of base-data, changing every now and then. At that point a I sendmessage to inform all open windows. Every window catch this message and refreshes data (mostly combos), if it is using it.
Yes, you need to implement a few lines of code in every window.

Well, users on other stations will not get these local messages. Whenever I need that too, I use HSendMessageToClient() to inform every other client. Works great.
I.e. refreshing a scheduler on every station wenever an appointment changes.
Only useable on HFCS.

von Arie - am 26.01.2012 18:43
Paolo, Arie,

Thanks for your feedback.
I'll think of an alternative for "use", because I suspect it to cause other problems too.
@Arie: I'm afraid to use a refresh triggered by a sendmessage. It will require a lot of coding. You will have to find out if the user is not using the combo or the table before you can update it. So it needs code in the combos and the tables too.
I'll stick to the "passive" update.

Regards,
Piet

von Piet van Zanten - am 27.01.2012 13:01
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.