CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2000
    Location
    Virginia, USA
    Posts
    9

    ADO and Asynchronous Execution

    I've been trying to use the adExecuteAsynch option on one of my ADO commands and VB doesn't seem to recognize the constant. What's up? How do I get my recordset to keep on returning while continue on in the code?


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: ADO and Asynchronous Execution

    Well, i dont think you can use your recordset until it done being populated. But here is some code that I use that seems to work for me...


    Dim rs as ADODB.Recordset
    Dim cn as ADODB.Connection
    Dim sql as string

    set cn = new ADODB.Connection

    cn.Open sConnectionString

    sql = "SELECT * FROM YourTable"

    set rs = new ADODB.Recordset

    set rs = cn.Execute(sql, , adAsyncExecute)

    While cn.State = adStateExecuting
    DoEvents
    Wend

    MsgBox "Done"




    Give that a whirl and see what happens. Oh BTW, one wierd little thing with executing asyncronously, when opening a recordset, the above while loop will work, but when executing an action query (INSERT, UPDATE) use this:

    While cn.State = adStateExecuting + adStateOpen
    DoEvents
    Wend




    I don't know why, but that seems to do it. This particular property isn't using bits, so I can't use the bitwise comparison method and this is the only way i got it to work.

    Good luck,
    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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