Asynchronous ODBCdirect queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dsatino
    Contributor
    • May 2010
    • 393

    #1

    Asynchronous ODBCdirect queries

    Ok, I'm not going to post any code at this point because there's a lot and I'm pretty sure my break point is caused outside of the module it's showing in.

    I have a local table that is a line item collection of related data from multiple sources. I'm trying to update this table using up to 7 asynchronous queries. In other words 7 queries simultaneously updating 1 table. None of the queries will ever try to update the same piece of data so I thought I could get away with this. I'm also not reusing any variables for workspaces, connections, or recordsets so that shouldn't be a problem.

    I am using the same variable for the local recordset that's being updated though.

    Most of the time, I get an error that says:

    "A different operation is preventing this operation from being executed"

    Am I trying to do too much? Am I missing something conceptually? If anyone has any ideas or can give me a general once over on the ins and outs of asynchronous queries that would be great.

    Thx
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    By simultaneous you mean they run at the same time? Not one after the other? How do you even make them run like that?

    Comment

    • dsatino
      Contributor
      • May 2010
      • 393

      #3
      You need to set up multiple odbcDirect workspaces. As long as each is operating in its own space, you can run them asynchronously.

      I should clarify though that these are DAO recordsets based on select queries and are not any type of action queries.
      For Example:

      With odbc1
      set rstEX=cnxABC.Op enRecordset("Se lect Field1, Field2, etc.",dbopendyn amic, dbrunasync)
      End with

      With odbc2
      set rstEX2=cnxABC2. OpenRecordset(" Select Field1, Field2, etc.",dbopendyn amic, dbrunasync)
      End with

      I'm then running a Do Until .eof Loop on each recordset and comparing it to values in my local recordset. I'm running 7 of these simultaneously, at least. These 7 asynch queries are embedded in another loop that runs twice (with different parameters on the second pass) so it's possible that more are open.

      Actually, now that I write this I realize it may be failing because i'm not pausing the operation so that the second loop can't start before the first one ends and I may be killing my first attempt by trying to start the second.

      I'll let you know if I can get this to work...

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        I still have no usefull advice to give :P, however I am curious as to why you need to run them in such a way, and not simply one after another?

        Comment

        • dsatino
          Contributor
          • May 2010
          • 393

          #5
          Need? Need,you ask.

          Why does Germany need a fresh central forward in a 3-nil game against a 10-man side?

          Because 4-nil is simply better.

          Or, in my case, because 30 seconds of processing is better than 3 minutes of processing.

          :)

          All joking aside, I obviously don't really need to do this. I'm simply trying to push the boundaries of my own programming capabilities.

          Comment

          Working...