Visual Studio 2008 TableAdapters and Transactions

Discussion in 'ASP .Net' started by Andrew Jocelyn, Mar 25, 2008.

  1. Hi

    I've just discovered that the typed DataSet tool now adds a Transaction
    property to each TableAdapter. The modifier is internal. It seems to be
    undocumented. Are there any examples/best practices on how to use it?

    Thanks
    Andrew
    Andrew Jocelyn, Mar 25, 2008
    #1
    1. Advertising

  2. Hi Andrew,

    As for the "Transaction" property of the VS generated TableAdapter, it
    actually wrapper the Transaction property on each Command object used in
    that TableAdapter. Here is an example of the generated "Transaction"
    property (in a certain TableAdapter):

    ===================
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    internal global::System.Data.SqlClient.SqlTransaction Transaction {
    get {
    return this._transaction;
    }
    set {
    this._transaction = value;
    for (int i = 0; (i < this.CommandCollection.Length); i = (i
    + 1)) {
    this.CommandCollection.Transaction =
    this._transaction;
    }
    if (((this.Adapter != null)
    && (this.Adapter.DeleteCommand != null))) {
    this.Adapter.DeleteCommand.Transaction =
    this._transaction;
    }
    if (((this.Adapter != null)
    && (this.Adapter.InsertCommand != null))) {
    this.Adapter.InsertCommand.Transaction =
    this._transaction;
    }
    if (((this.Adapter != null)
    && (this.Adapter.UpdateCommand != null))) {
    this.Adapter.UpdateCommand.Transaction =
    this._transaction;
    }
    }
    }
    ===============

    As you can see, when you set its value, it will update all the Command
    objects(used in this TableAdapter) and synchronize those commands'
    "Transaction' property to the same one. This is used when you use the old
    means to perform Transaction in ADO.NET:

    #SqlConnection..::.BeginTransaction Method
    http://msdn2.microsoft.com/en-us/library/86773566.aspx

    By setting the Transaction on the TableAdapeter, you make sure all the
    commands involved in the TableAdapter get set to the same transaction.

    In ADO.NET 2.0, it provides a more convenient Transaction model:


    #Transaction Processing in ADO.NET 2.0
    http://www.15seconds.com/issue/040914.htm

    #Working with Transactions in ADO.NET
    http://www.15seconds.com/issue/040914.htm

    Hope this help some.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: "Andrew Jocelyn" <>
    >Subject: Visual Studio 2008 TableAdapters and Transactions
    >Date: Tue, 25 Mar 2008 17:15:05 -0000
    >
    >Hi
    >
    >I've just discovered that the typed DataSet tool now adds a Transaction
    >property to each TableAdapter. The modifier is internal. It seems to be
    >undocumented. Are there any examples/best practices on how to use it?
    >
    >Thanks
    >Andrew
    >
    >
    >
    Steven Cheng [MSFT], Mar 26, 2008
    #2
    1. Advertising

  3. Hi Steven

    Thanks for the information. Actually I'm only interested in grouping
    TableAdapters into one SQL transaction. I have a solution using partial
    classes with the code generated TableAdapter classes in VS2005. However,
    VS2008 now generates a Transaction property which was breaking my code in
    the partial classes because I already had a method called Transaction with
    the same signiture. I was hoping that grouping TableAdapters together in
    VS2008 might be easier so I just wondered if you had any suggestions.

    Thanks
    Andrew
    Andrew Jocelyn, Mar 31, 2008
    #3
  4. Thanks for your reply Andrew,

    So you originally have your own encapsulatd Transaction property which
    conflict with the auto-genearted property in vs 2008, correct? If so, will
    the auto-generated one fit your requirement since it also associate with
    all the Commands object within the TableAdapter. You can use it to assign a
    certain SqlTransaction. Or otherwise, you may using the
    System.Transactions namespace's TransactionScope to perform transaction.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "Andrew Jocelyn" <>
    >References: <>

    <>
    >Subject: Re: Visual Studio 2008 TableAdapters and Transactions
    >Date: Mon, 31 Mar 2008 21:22:07 +0100
    >
    >Hi Steven
    >
    >Thanks for the information. Actually I'm only interested in grouping
    >TableAdapters into one SQL transaction. I have a solution using partial
    >classes with the code generated TableAdapter classes in VS2005. However,
    >VS2008 now generates a Transaction property which was breaking my code in
    >the partial classes because I already had a method called Transaction with
    >the same signiture. I was hoping that grouping TableAdapters together in
    >VS2008 might be easier so I just wondered if you had any suggestions.
    >
    >Thanks
    >Andrew
    >
    >
    >
    Steven Cheng [MSFT], Apr 3, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thirumalai
    Replies:
    0
    Views:
    646
    Thirumalai
    May 22, 2006
  2. Goofy

    TableAdapters Visual Studio 2005

    Goofy, Dec 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    314
    Goofy
    Dec 20, 2006
  3. HRsoft Informática

    Visual Web Express 2008 X Visual Studio Pro 2008

    HRsoft Informática, Jun 8, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    709
    Cowboy \(Gregory A. Beamer\)
    Jun 9, 2008
  4. Julien
    Replies:
    1
    Views:
    2,064
    Cowboy \(Gregory A. Beamer\)
    May 18, 2009
  5. Chen
    Replies:
    4
    Views:
    1,372
Loading...

Share This Page