CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2000
    Location
    Ohio
    Posts
    238

    Wait for completion of Execute command

    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



  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Wait for completion of Execute command

    Assuming you are using Asynchronous RDO try:

    While GetInitialRS.StillExecuting
    DoEvents
    Wend




    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Wait for completion of Execute command

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Nov 2000
    Location
    Ohio
    Posts
    238

    Re: Wait for completion of Execute command

    Actually,
    Im working on some fairly old code, probably about 3 years old now and they were using DAO
    any suggestions there?



  5. #5
    Join Date
    Nov 2000
    Location
    Ohio
    Posts
    238

    Re: Wait for completion of Execute command

    Nevermind on the last message. I understand what your saying... it worked fine. Thanks alot
    Joe



  6. #6
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Wait for completion of Execute command

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured