Click to See Complete Forum and Search --> : Wait for completion of Execute command


Joe Keller
April 2nd, 2001, 08:42 AM
Anyone know how to pause the code until an SQL statement is finished on a database.

The problem is.. im running an SQL statement that creates a table, by querying other tables and sorting the data.

strSQL = "SELECT * INTO tmp_SelectRes IN '" & g_Scdl.ScdlFileName & "' FROM tmp_Select " & strWhere & strOrder
g_dbCatalog.Execute strSQL

Set GetInitialRS = g_Scdl.dbSchedule.OpenRecordset("tmp_SelectRes")

the strWhere and strOrder strings are developed previously in the program.

The problem is, it takes the sql statement a while to do the ORDER BY command, so when the program immediately jumps to the next line and opens the table, the data is there, just not sorted correctly. I need to wait until this sort is finished before I open the table.

HELP! please!

Thanks
Joe

Clearcode
April 2nd, 2001, 09:57 AM
Assuming you are using Asynchronous RDO try:

While GetInitialRS.StillExecuting
DoEvents
Wend




-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

Iouri
April 2nd, 2001, 10:00 AM
If in your connection you will use Client cursor (cn.CursorLocation = adUseClient) I believe that program is waiting to execute until recordset is open.

Iouri Boutchkine
iouri@hotsheet.com

Joe Keller
April 2nd, 2001, 10:05 AM
Actually,
Im working on some fairly old code, probably about 3 years old now and they were using DAO
any suggestions there?

Joe Keller
April 2nd, 2001, 10:21 AM
Nevermind on the last message. I understand what your saying... it worked fine. Thanks alot
Joe

Iouri
April 2nd, 2001, 10:34 AM
if you switch to ADO and decide to use async connection, then you can use the following commands

adStateClosed Default. Indicates that the object is closed.
adStateOpen Indicates that the object is open.
adStateConnecting Indicates that the Recordset object is connecting.
adStateExecuting Indicates that the Recordset object is executing a command.
adStateFetching Indicates that the rows of the Recordset object are being fetched.


Iouri Boutchkine
iouri@hotsheet.com