PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET RE: Extending TableAdapters for Transactions in VB.Net

Reply

RE: Extending TableAdapters for Transactions in VB.Net

 
Thread Tools Rate Thread
Old 29-12-2006, 11:48 PM   #1
=?Utf-8?B?SGF3aw==?=
Guest
 
Posts: n/a
Default RE: Extending TableAdapters for Transactions in VB.Net


Ciaron thank you for your offer I have posted the code I found below.
In my case I have a typed Dataset with the name Schedules and 7 table
adapters associated with it I want to have the table adapters transaction
property usable from my Asp.net code behind pages. Anyway here is the C#
code.

Thank you,
Hawk

partial class CategoriesTableAdapter
{
public SqlTransaction Transaction
{
get { return _adapter.SelectCommand.Transaction; }
set
{
if (_adapter == null)
{
InitAdapter();
}

_adapter.InsertCommand.Transaction = value;
_adapter.UpdateCommand.Transaction = value;
_adapter.DeleteCommand.Transaction = value;
}
}
}

As you can see, the property assigns the given transaction to the
Transaction property on all its commands. This means I can do this in my
Update method:

CategoriesTableAdapter catsTA = new CategoriesTableAdapter();
CategoryCodesTableAdapter codesTA = new CategoryCodesTableAdapter();
AllocationsTableAdapter allocsTA = new AllocationsTableAdapter();
CostsTableAdapter costsTA = new CostsTableAdapter();

catsTA.Connection.Open();
try
{
SqlTransaction txn = catsTA.Connection.BeginTransaction();
try
{
catsTA.Transaction = txn;
codesTA.Transaction = txn;
allocsTA.Transaction = txn;
costsTA.Transaction = txn;

// update each table, commit transaction or
// rollback if there's a problem



"Ciaran O''Donnell" wrote:

> Post the c# and i'll convert it for you. Also, check out
> System.Transactions.TransactionScope. it's built in transaction handling for
> everything upto distributed transactions
>
>
> --
> Ciaran O''''Donnell
> http://wannabedeveloper.spaces.live.com
>
>
> "Hawk" wrote:
>
> > Ok, I have searched and searched with no luck trying to find a solid example
> > written in VB.Net on how to extend a tableadapter “Typed Dataset” within the
> > partial class to expose a transaction that can be used in my Asp.net pages.
> > Currently I am writing an Asp.net application that uses tableadapters as the
> > data access source. So far my app works and the tableadapters are simple to
> > use but I now need to include a transaction. I have heard and seen some
> > examples that use C# but I have not been able to translate this into VB.Net
> > at least where it works. Can someone point me in the right direction? It
> > seems like it should be simple but I just need a starting point.
> >
> > Thank you,
> > Hawk
> >

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off