Transaction and TypedDataSEt

Discussion in 'ASP .Net' started by liming, May 19, 2006.

  1. liming

    liming Guest

    Hi,

    I know it's possible to have transactions with Typed DataSet, but I have yet
    to find an example of it.

    For example, I have two typed TableAdapter

    CommerceDataSet.xsd

    CustomerTableAdapater

    Insert(@CustomerName)

    OrdersTableAdapater

    Insert(@CustomerID, @ProductID)

    My sample code

    CustomerTableAdapater customer = new CustomerTableAdapater();
    OrdersTableAdapater orders = new OrdersTableAdapater();
    String customername = blah;
    int customerid = 0, productid=0;
    .....
    ......
    customer.insert(customername);
    .....
    orders.insert(customerid,productid);

    ....



    How do I hook up transaction to both "Insert" method, if one fails, roll
    back? I have projects to finish up quickly in a month, and I prefer to use
    these typed datatable as my datalayer for now as it does mostly what I
    needed instead of implementing a whole layer myself manually using
    EnterpriseLibrary which really gets me the same result against sql server
    2000. Once I have this transaction issue resolved, I'm good to go.

    Another question, what's your opinion in terms of implement my data layer
    using Typed DataSet instead of my own classes? I do it right now beause it's
    quicker, mainly saves me a lot keystrokes considerably. What other benefit
    do you see? Just curious.

    Thanks
     
    liming, May 19, 2006
    #1
    1. Advertising

  2. Hello liming,

    Welcome to the MSDN newsgroup.

    From your description, I understand you're wondering the proper means to
    perform transaction control when using multiple ADO.NET
    tableadapter/typeddataset components in .NET application, correct?

    As for ADO.NET, it used to provide connection specific transaction support,
    that means the transaction's scope is limited to a single connection. Such
    single connection specific transaction is started by calling the
    "Connection.BeginTransaction" method and associating other command objects
    with the returned transaction instance. According to your scenario, you
    have multiple TableAdapters (each of them will have a connection object
    associated with it), then I think you can consider use the new transaction
    control feature provided in the .NET framework 2.0, it is under the
    "System.Transaction" namespace.

    You can just create a "TransactionScope" class instance and wrap other
    connections/commands's creation code within this "TransactionScope"
    instance's lifecycle, this will help implicitly establish a transaction
    context. Here are some msdn articles mentioned this:

    #Implementing an Implicit Transaction using Transaction Scope
    http://msdn2.microsoft.com/en-us/ms172152.aspx

    #System.Transactions Namespace
    http://msdn2.microsoft.com/en-us/system.transactions.aspx

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], May 22, 2006
    #2
    1. Advertising

  3. Hi Liming,

    How are you doing on this issue? Does the information in my last reply
    helps you a little? BTW, if you have any data access specific questions,
    you can also post in the microsoft.public.dotnet.framework.adonet
    newsgroup. There are also many ADO.NET experienced guys there who can help
    you.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], May 24, 2006
    #3
  4. liming

    PeterKellner Guest

    On Wed, 24 May 2006 11:54:55 GMT, (Steven
    Cheng[MSFT]) wrote:

    >Hi Liming,
    >
    >How are you doing on this issue? Does the information in my last reply
    >helps you a little? BTW, if you have any data access specific questions,
    >you can also post in the microsoft.public.dotnet.framework.adonet
    >newsgroup. There are also many ADO.NET experienced guys there who can help
    >you.
    >
    >Regards,
    >
    >Steven Cheng
    >Microsoft Online Community Support


    Steven,

    Not sure how Liming is doing, but you post helped me a lot. I had the
    some wonder and before this didn't know about transaction scope.
    Thanks.
    Peter Kellner
    http://peterkellner.net
     
    PeterKellner, May 24, 2006
    #4
  5. Thanks for your input Peter,

    Glad to be of assistance!

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], May 25, 2006
    #5
    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. msnews.microsoft.com
    Replies:
    2
    Views:
    2,338
    Brock Allen
    Mar 29, 2005
  2. andrea

    transaction and access

    andrea, Feb 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    343
    andrea
    Feb 28, 2006
  3. steven
    Replies:
    0
    Views:
    322
    steven
    Aug 21, 2008
  4. David

    TypedDataSet doesnot pass correctly in Web service

    David, May 31, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    125
    David
    May 31, 2004
  5. Vencz Istv?n
    Replies:
    2
    Views:
    304
Loading...

Share This Page