Using Dataset and DAAB as DAL (VB.net)

Topics: Data Access Application Block
Nov 8, 2007 at 3:02 PM
Dear All,

i did a try to use VS 2005 dataset and table adapters with DAAB as DAL , all i need to do is modefy the _adapter from protected to friend then i create a module that hold the database object then a update function as following :
-----------------------------------------------------
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Common

Module MdlDAL
Friend DbRisk As Database
Friend Ds As New DsRisk

Friend tadpAccounts As New DsRiskTableAdapters.TblAccountTableAdapter

Sub FillTblAccountsf()
Dim daptAccounts As SqlClient.SqlDataAdapter = tadpAccounts.Adapter
Dim strTables() As String = tblAccount
DbRisk = DatabaseFactory.CreateDatabase("Risk")

DbRisk.LoadDataSet(CommandType.Text, daptAccounts.selectCommand.commandtext, Ds, strTables)
End Sub

Function UpdateTblAccounts() As Integer
Dim daptAccounts As SqlClient.SqlDataAdapter = tadpAccounts.Adapter
Dim Rows As Integer = DbRisk.UpdateDataSet(Ds, "TblAccount" _
, daptAccounts.InsertCommand _
, daptAccounts.UpdateCommand _
, daptAccounts.DeleteCommand _
, UpdateBehavior.Transactional)

Return Rows
End Function
End Module

-------------------------------------------------------------

then i used the funtions as following :

FillTblAccountsf()
.
.
.
.
.
.
MessageBox.Show(UpdateTblAccounts.ToString)

the only thing that annoing any modification to dataset desinger it restore the protected _adapter , i have to remodifyed to friend


hope that you would like that.

Regards,
Amr