VB6 - DAO Begin/Commit & Rollback 
Author Message
 VB6 - DAO Begin/Commit & Rollback

Could someone tell me why I cant get these three to work. I used them in
earlier versions with the following

Old code

    dim db as database
    dim tb as table

    set db = opendatabase("dbfile")
    set tb =  db.OpenTable("authors")

    db.begintrans

    store lots of records here

    db.commit

    tb.close
    db.close

newcode

    dim db as database
    dim rs as recordset

    set db = opendatabase("dbfile")
    set rs =  db.OpenRecordset("authors")

    db.begintrans

    store lots of records here

    db.commit

    rs.close
    db.close

I have now change the Tables to Recordsets and it appears to work, apart
from the begin, commit & rollback

what is wrong!

Derrick



Mon, 28 Jan 2002 03:00:00 GMT  
 VB6 - DAO Begin/Commit & Rollback
Derrick,

According to my VB5 documentation, BeginTrans, CommitTrans and Rollback are
methods of the Workspace object, not the database object.

Hope this helps,

Kerry Moorman


Quote:
>Could someone tell me why I cant get these three to work. I used them in
>earlier versions with the following

>Old code

>    dim db as database
>    dim tb as table

>    set db = opendatabase("dbfile")
>    set tb =  db.OpenTable("authors")

>    db.begintrans

>    store lots of records here

>    db.commit

>    tb.close
>    db.close

>newcode

>    dim db as database
>    dim rs as recordset

>    set db = opendatabase("dbfile")
>    set rs =  db.OpenRecordset("authors")

>    db.begintrans

>    store lots of records here

>    db.commit

>    rs.close
>    db.close

>I have now change the Tables to Recordsets and it appears to work, apart
>from the begin, commit & rollback

>what is wrong!

>Derrick



Mon, 28 Jan 2002 03:00:00 GMT  
 VB6 - DAO Begin/Commit & Rollback
mmm, I thought that might be it, so have tried to use the workspace (with
the code below), but can't get it to work!!!. The line Set ws returns 3028
error

    dim ws as workspace
    dim db as database
    dim rs as recordset

    set ws = CreateWorkspace("", "dk", "")
    set db = opendatabase("dbfile")
    set rs =  db.OpenRecordset("authors")

    db.begintrans

    store lots of records here

    db.commit

    rs.close
    db.close

I have now change the Tables to Recordsets and it appears to work, art
from the begin, commit & rollback

what is wrong!

Derrick



Mon, 28 Jan 2002 03:00:00 GMT  
 VB6 - DAO Begin/Commit & Rollback
Derrick,

You don't need to explicitly create the workspace.  VB will use the default
workspace.  You might try opening the database like this:

Set db = DBEngine.Workspaces(0).OpenDatabase("dbfile")

Then use the BeginTrans, etc methods without using the database qualifier:

    Instead of

        db.BeginTrans

use

        BeginTrans

Hope this helps,

Kerry


Quote:
>mmm, I thought that might be it, so have tried to use the workspace (with
>the code below), but can't get it to work!!!. The line Set ws returns 3028
>error

>    dim ws as workspace
>    dim db as database
>    dim rs as recordset

>    set ws = CreateWorkspace("", "dk", "")
>    set db = opendatabase("dbfile")
>    set rs =  db.OpenRecordset("authors")

>    db.begintrans

>    store lots of records here

>    db.commit

>    rs.close
>    db.close

>I have now change the Tables to Recordsets and it appears to work, art
>from the begin, commit & rollback

>what is wrong!

>Derrick



Mon, 28 Jan 2002 03:00:00 GMT  
 VB6 - DAO Begin/Commit & Rollback
THats cracked it, thanks very much for the help

erm I am having a bit of a problem with .SORT and .FILTER, also within
database access. I am assuming that the way to get sround this is to open a
recordset with a sql statement to include the filter and sort? (something
like 'select * from tablename with name = "derrick" orderby dob')

Quote:

>Derrick,

>You don't need to explicitly create the workspace.  VB will use the default
>workspace.  You might try opening the database like this:

>Set db = DBEngine.Workspaces(0).OpenDatabase("dbfile")

>Then use the BeginTrans, etc methods without using the database qualifier:

>    Instead of

>        db.BeginTrans

>use

>        BeginTrans

>Hope this helps,

>Kerry



>>mmm, I thought that might be it, so have tried to use the workspace (with
>>the code below), but can't get it to work!!!. The line Set ws returns 3028
>>error

>>    dim ws as workspace
>>    dim db as database
>>    dim rs as recordset

>>    set ws = CreateWorkspace("", "dk", "")
>>    set db = opendatabase("dbfile")
>>    set rs =  db.OpenRecordset("authors")

>>    db.begintrans

>>    store lots of records here

>>    db.commit

>>    rs.close
>>    db.close

>>I have now change the Tables to Recordsets and it appears to work, art
>>from the begin, commit & rollback

>>what is wrong!

>>Derrick



Mon, 28 Jan 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Begin-Rollback-Commit Transaction

2. Workspace Transaction Begin/Commit/Rollback bug?

3. Limits on Transactions between Begin & Commit

4. workspace commit/rollback

5. Commit/Rollback spanning procedures

6. DB Commit\Rollback Issues

7. How does .commit and .rollback work?

8. VB4 - Commit or Rollback without BeginTrans. (Error 3034)

9. Commit and Rollback

10. Using commit/rollback with Oracle and RDO

11. BeginTrans Commit RollBack

12. BeginTrans, Commit, RollBack

 

 
Powered by phpBB® Forum Software