Nabil,
All your DataAccess should be in your DataAccess layer, so that is where you should be doing the transactions. Your UI should not be doing anything to call the back end directly. In fact, your UI shouldn't even be calling the DataAccess layer, you should have a Business layer in between.
Just my 2 cents ...
~~Bonnie
>I am creating a MultiTier application , I created a abstract form in a dll, I referenced the dll in my project , I want to handle a transaction whithin the abstract form , while my dataadaptors are in another dll.
>What is the best approach?
>
>I have done this code but I am getting this error on the call to commit the transaction
>"Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized."
>
>
>Mycode is as follows:
>1- AbstractForm Code
>'''retrieve button
> Dim tr As IDbTransaction
> tr = BeginTransaction(m_Connection)
> dim dt as datatable
> getData(dt)
> grdData.datasource=dt
>'''Save button
> SaveData(dt)
> tr=CommitTransaction(m_Connection, tr) ' error comes here
>
>2- EmployeeForm which inherits from AbstractForm
> Sub MustOverrides getData(dt as datatable)
> RetrieveEmployee(dt)
> End Sub
> Sub MustOverrides SaveData(dt as datatable)
> SaveEmployee(dt)
> End Sub
>
>3- DataAccessLayerCode
> Sub RetrieveEmployee(ByVal dt As dsEmployees.EmployeesDataTable)
> daEmployee.Fill(dt)
> End Sub
>
> Sub SaveEmployee(ByVal dt As dsEmployees.EmployeesDataTable)
> daEmployee.Update(dt)
> End Sub
>
>4- General Dll Code
>Public Shared Function BeginTransaction(ByRef rcon As IDbConnection) As IDbTransaction
> Dim il As IsolationLevel = IsolationLevel.RepeatableRead
> If rcon.State = ConnectionState.Closed Then
> rcon.Open()
> End If
> Return CType(rcon.BeginTransaction(il), IDbTransaction)
>End Function
>
>Public Shared Function BeginTransaction(ByRef rcon As IDbConnection,_
> ByVal il As IsolationLevel) As IDbTransaction
> If rcon.State = ConnectionState.Closed Then
> rcon.Open()
> End If
> Return CType(rcon.BeginTransaction(il), IDbTransaction)
>End Function