|
-
Apr 16th, 2013, 12:45 PM
#1
Thread Starter
PowerPoster
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
-
Apr 16th, 2013, 01:33 PM
#2
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
-
Apr 16th, 2013, 02:13 PM
#3
Thread Starter
PowerPoster
Re: Transa tion and with stement
 Originally Posted by techgnome
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
-
Apr 16th, 2013, 02:18 PM
#4
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
-
Apr 16th, 2013, 02:37 PM
#5
Thread Starter
PowerPoster
Re: Transa tion and with stement
 Originally Posted by techgnome
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???
-
Apr 16th, 2013, 02:55 PM
#6
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
-
Apr 16th, 2013, 03:59 PM
#7
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|