[HELP] EnterpriceLibarary UpdateDataSet

Topics: Enterprise Library Core
May 20, 2015 at 2:03 PM
Hi All,

Currently Im using Microsoft EnterpriceLibrary "UpdateDataSet" to insert all the data in one times,
Microsoft.Practices.EnterpriseLibrary.Data.Database.UpdateDataSet(DataSet dataSet, String tableName, DbCommand insertCommand, DbCommand updateCommand, DbCommand deleteCommand, UpdateBehavior updateBehavior)
But the problem is the my dataset contains 2 Datatable, how can i consume the library "UpdateDataSet" with my case?

_defaultDB.UpdateDataSet(dsData, "Main", cmd, NULL, NULL, UpdateBehavior.Standard

Thanks your help.
Sep 7, 2015 at 6:52 PM
Hi Garyboyz,

You would need to use a transaction, like shown below:
        Dim objDatabase As New Database

        Using objConnection As DbConnection = objDatabase.CreateConnection()
            Call objConnection.Open()

            Dim objTransaction As DbTransaction = objConnection.BeginTransaction()


                ' Update all tables
                Call objDatabase.UpdateDataSet(dstDataSet, strTable1, objInsertCommand1, objUpdateCommand1, objDeleteCommand1, objTransaction)
                Call objDatabase.UpdateDataSet(dstDataSet, strTable2, objInsertCommand2, objUpdateCommand2, objDeleteCommand2, objTransaction)

                ' Commit the transaction
                Call objTransaction.Commit()

            Catch ex As Exception
                Call objTransaction.Rollback()

            End Try

            Call objConnection.Close()
        End Using