Hi,
1.Our application involves a 3 tier architecture .Could u kindly send us a sample code for 3 tier architecture using VB.The SetComplete and the SetAbort functionality is not working for us as intended.The state of the objectcontext object is lost across the DLL boundaries so please tell us how to come over this problem.
Ex.
-------------------------------------------------------
This is the Form level EXE, which references business layer DLL(Test).
(Test --- ProjectName ; busTesting --- ClassName)
--------------------------------------------------------
Public sub subCheck()
Dim recValues as adodb.recordset
Dim objbusTesting as new Test1.busTesting
Dim intProjectid as integer
set recValues = objbusTesting.funGetValues(intprojectid)
End sub
------------------------------------------------------
This is the Business layer DLL which references the data layer DLL
--------------------------------------------------------
Public function funGetValues(byval intProjectid as integer) as adodb.recordset
On error GoTo errorhandler
Dim intProjectid as integer
Dim recFields as adodb.recordset
Dim objcon as Mtxas.objectcontext
set objcon = Getobjectcontext()
Dim objtboTesting as Test2.tboTesting
set objtboTesting = objcon.createinstance("Test2.tboTesting"
Set recFields = objtboTesting.funGetRecords(intProjectid)
set funGetValues = recFields
objcon.SetComplete
set recFields = nothing
set objcon = nothing
Exit function
errorhandler:
objcon.SetAbort
End function
--------------------------------------------
This is the Data Layer DLL
--------------------------------------------
Public function funGetRecords(byval intprojectid as integer) as adodb.recordset
On error goto errorhandler
Dim conn as adodb.connection
Dim strsql as string
Dim recopen as adodb.recordset
strsql = "select * from Testing where projectid = " & intprojectid
recopen.cursortype= adopenkeyset
recopen.locktype = adlockoptimistic
recopen.open strsql
set funGetRecords = recopen
Getobjectcontext.setcomplete()
Exit function
Errorhandler:
Getobjectcontext.setAbort()
End function
-------------------------------------------------------
This is the Sample Code which we use,in this we reference the Microsoft Transaction Server Type Library.Do we need to reference something else also.I would like to hear soon from you.In this case if any error occurs we need to Set Abort the entire transaction but the problem here it is not holding the same objectContext instance everywhere .Everytime it begins a new transaction which we don't want.The MTS transaction property for the Business object is set to REQUIRES A NEW TRANSACTION and for the table object is SUPPORTS TRANSACTION.When we do a set abort in the business it sets abort only that particular transaction and according to MTS even if we commit the transaction the table object it temporarily commits it and the only commits in the database in the Business object which is the root of the transaction.This does not work for me.It commits in the database and when any error comes it does not rollback the entire data but only rollbacks that specific transaction or data.Please reply ASAP.
Thanks,
Jairam
1.Our application involves a 3 tier architecture .Could u kindly send us a sample code for 3 tier architecture using VB.The SetComplete and the SetAbort functionality is not working for us as intended.The state of the objectcontext object is lost across the DLL boundaries so please tell us how to come over this problem.
Ex.
-------------------------------------------------------
This is the Form level EXE, which references business layer DLL(Test).
(Test --- ProjectName ; busTesting --- ClassName)
--------------------------------------------------------
Public sub subCheck()
Dim recValues as adodb.recordset
Dim objbusTesting as new Test1.busTesting
Dim intProjectid as integer
set recValues = objbusTesting.funGetValues(intprojectid)
End sub
------------------------------------------------------
This is the Business layer DLL which references the data layer DLL
--------------------------------------------------------
Public function funGetValues(byval intProjectid as integer) as adodb.recordset
On error GoTo errorhandler
Dim intProjectid as integer
Dim recFields as adodb.recordset
Dim objcon as Mtxas.objectcontext
set objcon = Getobjectcontext()
Dim objtboTesting as Test2.tboTesting
set objtboTesting = objcon.createinstance("Test2.tboTesting"
Set recFields = objtboTesting.funGetRecords(intProjectid)
set funGetValues = recFields
objcon.SetComplete
set recFields = nothing
set objcon = nothing
Exit function
errorhandler:
objcon.SetAbort
End function
--------------------------------------------
This is the Data Layer DLL
--------------------------------------------
Public function funGetRecords(byval intprojectid as integer) as adodb.recordset
On error goto errorhandler
Dim conn as adodb.connection
Dim strsql as string
Dim recopen as adodb.recordset
strsql = "select * from Testing where projectid = " & intprojectid
recopen.cursortype= adopenkeyset
recopen.locktype = adlockoptimistic
recopen.open strsql
set funGetRecords = recopen
Getobjectcontext.setcomplete()
Exit function
Errorhandler:
Getobjectcontext.setAbort()
End function
-------------------------------------------------------
This is the Sample Code which we use,in this we reference the Microsoft Transaction Server Type Library.Do we need to reference something else also.I would like to hear soon from you.In this case if any error occurs we need to Set Abort the entire transaction but the problem here it is not holding the same objectContext instance everywhere .Everytime it begins a new transaction which we don't want.The MTS transaction property for the Business object is set to REQUIRES A NEW TRANSACTION and for the table object is SUPPORTS TRANSACTION.When we do a set abort in the business it sets abort only that particular transaction and according to MTS even if we commit the transaction the table object it temporarily commits it and the only commits in the database in the Business object which is the root of the transaction.This does not work for me.It commits in the database and when any error comes it does not rollback the entire data but only rollbacks that specific transaction or data.Please reply ASAP.
Thanks,
Jairam