transaction not working Access 2K & SQL 7.0 via ODBC

  • Thread starter Thread starter Ahmed
  • Start date Start date
A

Ahmed

thank you for your help: i need to solve this.

i try to make that code work:

dim wks as workspace

set wks = dbengine.workspaces(0)
wks.BeginTrans

db.execute "insert into CLIENTS (ID, NOM) values (33, 'TEST')", dbseechanges

wks.CommitTrans

debug.print dlookup("nom","client","id=33") 'at this point, the program no
longer responds

if i do the same thing without using a transaction, it works.
the code do as if i did not do the CommitTrans action.

Thank you.
 
Thank you for reading my message.

dim db as database
set db=CurrentDB

where db is a global variable set at the very beginning of the program.
 
Ok, I'm mystified as to what could be happening.

Maybe try re-establishing the database reference before or after starting
the transaction?

set wks = dbengine.workspaces(0)
set db = wks.databases(0) ' <- here?
wks.BeginTrans
set db = wks.databases(0) ' <- here?
db.execute "insert into ...

But that really shouldn't make a difference.

See whether dbSeeChanges is causing it. Try dbFailOnError instead.

Try setting db and wks to nothing before the dlookup.

HTH,
TC
 
thank you for your response...

i just understood what the pb is...

the db variable have to be set AFTER the workspace object, in my case, i do
the oposite because :

- at the database launch i set wksLocal (workspace) as
dbengine.workspaces(0) and then db (database)
- in a sub i define another wks (workspace) as dbengine.workspaces(0) and
use the db variable set far before...

i hear you... you're right, that's stupid !

i've just made the correction...

thanks.
 
Back
Top