implementing sql transactions in data access layers

Discussion in 'ASP .Net' started by =?Utf-8?B?U3JpZGhhcg==?=, Oct 10, 2006.

  1. Hi,

    I am trying to implement sql transactions. But I am not knowing how to
    do that. I created a data access layer which contains methods to
    select/insert/update tables in a database. I have also created a business
    logic layer to retrieve/update the data from the data access layer. All of
    this is working fine if there are no transactions involved. If I need to use
    transactions, I am not knowing how to do that. Lets say I have a webform from
    which I want to insert 10 records into our database. I need to make sure that
    either all of them gets inserted or nothing gets inserted. so to do that I
    need to have sql transactions. So how should I wrap these insert statements
    inside transactions? Do I need to first get the sql connection object and
    create a transaction in the webform and attach that transaction to the sql
    connection object. And once all the transactions are done I would commit the
    transactions inside the web form. Is it right to get the sql connection from
    data access layer to the webform and implement the transactions? please let
    me know.

    Thanks,
    sridhar.
    =?Utf-8?B?U3JpZGhhcg==?=, Oct 10, 2006
    #1
    1. Advertising

  2. Here is some documentation to get you started:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daag.asp

    In the past, when I have needed transactions, I have not done them in
    the data layer, but within a stored procedure, recently though I have
    begun to toy with them within the data access layer, mainly with O/R
    Mappers.

    Transactions is a large topic, so reading the above link will give you
    the low down.

    hope it helps!

    Sean

    Sridhar wrote:
    > Hi,
    >
    > I am trying to implement sql transactions. But I am not knowing how to
    > do that. I created a data access layer which contains methods to
    > select/insert/update tables in a database. I have also created a business
    > logic layer to retrieve/update the data from the data access layer. All of
    > this is working fine if there are no transactions involved. If I need to use
    > transactions, I am not knowing how to do that. Lets say I have a webform from
    > which I want to insert 10 records into our database. I need to make sure that
    > either all of them gets inserted or nothing gets inserted. so to do that I
    > need to have sql transactions. So how should I wrap these insert statements
    > inside transactions? Do I need to first get the sql connection object and
    > create a transaction in the webform and attach that transaction to the sql
    > connection object. And once all the transactions are done I would commit the
    > transactions inside the web form. Is it right to get the sql connection from
    > data access layer to the webform and implement the transactions? please let
    > me know.
    >
    > Thanks,
    > sridhar.
    Sean Chambers, Oct 11, 2006
    #2
    1. Advertising

  3. Thank you.

    "Sean Chambers" wrote:

    > Here is some documentation to get you started:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daag.asp
    >
    > In the past, when I have needed transactions, I have not done them in
    > the data layer, but within a stored procedure, recently though I have
    > begun to toy with them within the data access layer, mainly with O/R
    > Mappers.
    >
    > Transactions is a large topic, so reading the above link will give you
    > the low down.
    >
    > hope it helps!
    >
    > Sean
    >
    > Sridhar wrote:
    > > Hi,
    > >
    > > I am trying to implement sql transactions. But I am not knowing how to
    > > do that. I created a data access layer which contains methods to
    > > select/insert/update tables in a database. I have also created a business
    > > logic layer to retrieve/update the data from the data access layer. All of
    > > this is working fine if there are no transactions involved. If I need to use
    > > transactions, I am not knowing how to do that. Lets say I have a webform from
    > > which I want to insert 10 records into our database. I need to make sure that
    > > either all of them gets inserted or nothing gets inserted. so to do that I
    > > need to have sql transactions. So how should I wrap these insert statements
    > > inside transactions? Do I need to first get the sql connection object and
    > > create a transaction in the webform and attach that transaction to the sql
    > > connection object. And once all the transactions are done I would commit the
    > > transactions inside the web form. Is it right to get the sql connection from
    > > data access layer to the webform and implement the transactions? please let
    > > me know.
    > >
    > > Thanks,
    > > sridhar.

    >
    >
    =?Utf-8?B?U3JpZGhhcg==?=, Oct 11, 2006
    #3
    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. DiscoStu
    Replies:
    3
    Views:
    2,174
    DiscoStu
    Sep 24, 2003
  2. EAI
    Replies:
    0
    Views:
    326
  3. kbutterly
    Replies:
    3
    Views:
    375
    kbutterly
    Jan 30, 2007
  4. David C. Barber
    Replies:
    3
    Views:
    538
  5. Savvoulidis Iordanis

    CODING PRACTICE. Business and Data Access Layers

    Savvoulidis Iordanis, Jul 20, 2008, in forum: ASP .Net
    Replies:
    7
    Views:
    329
    Savvoulidis Iordanis
    Jul 24, 2008
Loading...

Share This Page