Data Access Application Block/Nested Dataset/Transactions

  • Thread starter Thread starter John Zink
  • Start date Start date
J

John Zink

I am in the process of writing some WEB Services that will
receive a nested Dataset and have to apply any changes to
the appropriate tables. I am planning on using the Data
Access Application Block for my database calls. I have
the UpdateDataset method working, but now I want to add
transactional support. If the dataset contains changes to
table1, table2, and table3 I want to wrap the updates in a
transaction so I can roll back if necessary.
Any ideas on how the application block handles this ?
Do I have to modify the application block and add my own
custom code ?
 
I extended the Data Access Application Block to be able to fill
datasets (also typed datasets, with TableMapping) and to update tables
from the Dataset. I use a "Select" Stored Procedure and the other
Commands (Update, Insert, Delete) are created by a Command Builder.

Its not 100% clean, but if you are interested i could mail you the
code. It works like this:
- create a DataAdapter
- Build the Commands
- call .Update on the DataAdapter for a given DataTable

As the method accepts a Transaction and a Connection object as
parameter you can run updates on several tables sequentially and then
commit the transaction.

Here is the signature of the method in the SQLHelper:

public static void UpdateDataTable(SqlConnection connection,
SqlTransaction transaction, System.Data.CommandType selectCommandType,
string selectCommandText, DataTable dataTable, DataTableMapping[]
tableMapping)

Peter Gossmann
MCP for ASP.NET
 
Back
Top