Results 1 to 7 of 7

Thread: Transa tion and with stement

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Transa tion and with stement

    Example of my code:
    With rs
    For x= 0 to nn
    ..addnew
    .fields("a").value='gg'
    .fields("b).value='ff'
    .update
    Eccc..
    Next
    End with

    I nedd to insert abegin and commit tra s to speed up the write of data.


    Question:

    -Where a insert begin a d commit trans?
    - how to open the table for that?
    - in order of speeding and writing data (googoling..) a user suggest to use:
    !namers='ff'
    Instead
    .rs(....e cc
    Is correct?
    Note,
    I use adojet connetion and access and vb6 classic

    Tks

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Transa tion and with stement

    a transaction in this case is not going to speed things up, in fact it may actually slow things down... if you want to speed things up, then what you should do is get your recordset... disconnect it... add to it with the new data... then re-connect it and use an .UpdateBatch to send ALL of the changes to the database...

    Transactions are not used to speed things up.. .they are for data integrity reasons... take for example transferring money from one account to another. The process is simple: Take money from one account and deposit into the other. OK. Now let's say something happens in that moment between taking it out and depositing it in the other. W/o a transaction, the money has been taken out, but not deposited... so now not only are you late with the payment, but you're now short that amount. No good is it? So that's why you would you use a transaction... either ALL of the actions have to commit, or NONE of them do.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: Transa tion and with stement

    Quote Originally Posted by techgnome View Post
    a transaction in this case is not going to speed things up, in fact it may actually slow things down... if you want to speed things up, then what you should do is get your recordset... disconnect it... add to it with the new data... then re-connect it and use an .UpdateBatch to send ALL of the changes to the database...

    Transactions are not used to speed things up.. .they are for data integrity reasons... take for example transferring money from one account to another. The process is simple: Take money from one account and deposit into the other. OK. Now let's say something happens in that moment between taking it out and depositing it in the other. W/o a transaction, the money has been taken out, but not deposited... so now not only are you late with the payment, but you're now short that amount. No good is it? So that's why you would you use a transaction... either ALL of the actions have to commit, or NONE of them do.

    -tg
    hi Tg.. example based:

    get your recordset... disconnect it... add to it with the new data... then re-connect it and use an .UpdateBatch

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Transa tion and with stement

    you appear to already have the recordset, so that part's easy... you disconnect it by setting the active connection of the recordset to nothing... you have the code to add to it (just remove the update)... and then reconnecting it is a matter of setting the active connection... and well, I clued you in on the updateBatch method...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: Transa tion and with stement

    Quote Originally Posted by techgnome View Post
    you appear to already have the recordset, so that part's easy... you disconnect it by setting the active connection of the recordset to nothing... you have the code to add to it (just remove the update)... and then reconnecting it is a matter of setting the active connection... and well, I clued you in on the updateBatch method...

    -tg
    if i have undesrtand:

    rs.open....,3,3,cmdtable (is a good idea 3,3,???? in other case)

    DISCONNECT CONN TO NULL

    for x....

    Rs.addnew

    rs.fiElD.VALUE='333'

    rs.updatebatch
    next x

    RECONNECT CONN

    correct???

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Transa tion and with stement

    no... that's not quite what I said...


    1) Get your recordset:
    rs.open....,3,3,cmdtable (is a good idea 3,3,???? in other case)

    2) disconnect it:
    DISCONNECT CONN TO NULL

    for x....
    3) add your new records:
    Rs.addnew

    rs.fiElD.VALUE='333'

    next x

    4) Reconnect
    RECONNECT CONN

    5) call the update batch...
    rs.updatebatch


    The documentation that took 5 seconds to search for
    There's a link to a VB6 example on that page too...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: Transa tion and with stement

    Hi tg now all. Is clear...
    But i need to loop 133 txt files to get part of string line and put into the recorset.
    I need to open an close the conn for each
    txt file readed or i can to reconnect the conn when the loop of txt files is finished?
    Last edited by luca90; Apr 16th, 2013 at 04:25 PM.

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