15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


When to call BeginTrans

Mahesh Apte -- mahesha@surya.trddc.ernet.in
Wednesday, December 11, 1996

Environment :	VC++ 1.51 Windows 95

Hi there,

	For providing a transaction cycle, CDatabase provides functions viz. 
BeginTrans,
	CommitTrans and RollBack. For using these functions, help says that U 
should open all the recordsets that U will be using for transaction before 
BeginTrans. In our project, we have largeno of  tables. So opening all the 
recordsets is not feasible. Also we are using a database IO layer which 
does the actual db operation and we are doing BeginTrans at the task layer. 

	Ideally we want to do BeginTrans first , then call n function calls of IO 
layer which internally open it's recordset , do the transaction and close 
it. Then call CommitTrans or RollBack based on the return value of those 
functions. We tried it out and it worked. But help gives warning. So it may 
hit us anytime. So can anybody suggest some solution??

Help will be highly appreciated.
								Maha







wei@cmgroup.com
Friday, December 13, 1996

> Hi there,

> 	For providing a transaction cycle, CDatabase provides functions viz. 
> BeginTrans,
> 	CommitTrans and RollBack. For using these functions, help says that U 
> should open all the recordsets that U will be using for transaction before 
> BeginTrans. In our project, we have largeno of  tables. So opening all the 
> recordsets is not feasible. Also we are using a database IO layer which 
> does the actual db operation and we are doing BeginTrans at the task layer. 

> 	Ideally we want to do BeginTrans first , then call n function calls of IO 
> layer which internally open it's recordset , do the transaction and close 
> it. Then call CommitTrans or RollBack based on the return value of those 
> functions. We tried it out and it worked. But help gives warning. So it may 
> hit us anytime. So can anybody suggest some solution??
Ya. You can do it. The solution is just only make one CDatabase object
and pass a pointer of it to any CRecordset derived objects. And also 
any your direct SQL statement excution through this unique CDatabase object. 
You can Commit or RollBack any operation since last BeginTrans call.

You can put this CDatabase object pointer inside you CMainFrame class.
Then you easy access to it.

Hope this help.

Wei Sheng










Mahesh Apte -- mahesha@surya.trddc.ernet.in
Tuesday, December 17, 1996

[Mini-digest: 2 responses]

Thanx Wei ,

	Well we are already doing that. We have only one instance of CDatabase class.
	we are using it for all the recordsets. So do U mean that what we are doing will
	serve the purpose??
							Regards
							Maha

----------
From: 	wei@cmgroup.com[SMTP:wei@cmgroup.com]
Sent: 	Saturday, December 14, 1996 5:25 AM
To: 	mfc-l@netcom.com
Subject: 	Re:  When to call BeginTrans

> Hi there,

> 	For providing a transaction cycle, CDatabase provides functions viz. 
> BeginTrans,
> 	CommitTrans and RollBack. For using these functions, help says that U 
> should open all the recordsets that U will be using for transaction before 
> BeginTrans. In our project, we have largeno of  tables. So opening all the 
> recordsets is not feasible. Also we are using a database IO layer which 
> does the actual db operation and we are doing BeginTrans at the task layer. 

> 	Ideally we want to do BeginTrans first , then call n function calls of IO 
> layer which internally open it's recordset , do the transaction and close 
> it. Then call CommitTrans or RollBack based on the return value of those 
> functions. We tried it out and it worked. But help gives warning. So it may 
> hit us anytime. So can anybody suggest some solution??
Ya. You can do it. The solution is just only make one CDatabase object
and pass a pointer of it to any CRecordset derived objects. And also 
any your direct SQL statement excution through this unique CDatabase object. 
You can Commit or RollBack any operation since last BeginTrans call.

You can put this CDatabase object pointer inside you CMainFrame class.
Then you easy access to it.

Hope this help.

Wei Sheng
-----From: djs@sandyhook.com (David J. Straley)

Simply remember that each connection to the DB has its own
committ/rollback behavior.  So, then, if you have multiple DB
connections, you can open Recordsets on those individual connections
and have their commits & rollbacks dictated-to by the status of your
commits & rollbacks on the respective DB connections.

Regards,



              ---------------------------------
            David J. Straley  *  djs@sandyhook.com
     Sandy Hook Software Corp. *  http://www.sandyhook.com
       -- Software Development Outsourcing Services --




| Вернуться в корень Архива |