How to write Commit trasction

Last post 06-06-2007 2:49 AM by vijaya123. 10 replies.

Sort Posts:

  • How to write Commit trasction

    06-02-2007, 3:13 AM
    • Loading...
    • vijaya123
    • Joined on 05-19-2007, 3:10 AM
    • Posts 6

    Note from moderator XIII : this message was moved from the Oracle forums:

     

    i have create Business logic layer

    i want to implement begin transaction

    commit transaction.

    if data is not properly updated  -> Rollback trasaction

     

    thank you 

    vijaya@jyothy.com

     

     

     

    Filed under: , , ,
  • Re: How to write Commit trasction

    06-02-2007, 3:58 AM

    Hello,

    Assuming that you have coded the data logic by hand, and you have a connection instance which you use a command object against to complete the update, then something along the following lines:

    //Put the appropriate parts of thsi in your try block:

    SqlTransaction transaction = connection.BeginTransaction();//assumes a SqlConnection var named connection exists, and is open and otherwise configured

    command.Transaction = transaction;//assumes a SqlCommand var named command exists and is associated with the connection

    //Other code omitted

    command.Exec...();//Execute whatever is appropriate, NonQuery, Scalar etc...

    transaction.Commit();//if all goes well in the try block, then commit the transaction

    //put this part in your catch block:

    transaction.Rollback();//if something goes wrong, then roll it back

    Parts of above are written for the SQL provider, but AFAIK other managed providers use the same pattern so you will just need to substitute if required.

    If this is not what you were looking for, can you give us some indication as to how you are conducting your data access? Do you have a data access layer?

    HTH

    Aaron

  • Re: How to write Commit trasction

    06-02-2007, 4:01 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 6,476

     Are you able to contain the BEGIN, UPDATE AND COMMIT within an Oracle stored procedure? If so your ADO.NET will immensely simpler.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: How to write Commit trasction

    06-03-2007, 11:58 PM
    • Loading...
    • vijaya123
    • Joined on 05-19-2007, 3:10 AM
    • Posts 6

    I have created DAL through dataset for the database ( I have crated query for CRUD). Then I have written BLL for the query. Now in BLL I want to add commit while insertion, update, delete. BLL is Business logic layer. In that I it appears as Objects. For binding in the later case I can just map object to severside controls.

     

     

    vijaya

     

     

  • Re: How to write Commit trasction

    06-04-2007, 2:30 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 6,476

    You should endeavor to put the BEGIN TRANSACTION, UPDATES AND COMMIT all within one stored procedure.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: How to write Commit trasction

    06-04-2007, 3:19 AM
    • Loading...
    • vijaya123
    • Joined on 05-19-2007, 3:10 AM
    • Posts 6

     

    hello, i have master and detail data.

    for both i have written BLL.

    i may add 2 records in detail table , then i will abort it(transaction).

    this means master is not saved. then detail data corresponding to that, also must not save. so i must

    do all these things using 

     begin  transaction

    end transaction

    if transaction is successfull then commit it else rollback;

    how to do it?

     

     

    using System.Transactions;
    gives error.

    so if object is used how to control this. 

    Filed under:
  • Re: How to write Commit trasction

    06-04-2007, 7:26 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 6,476

    How many combinations of Master and Detail do you have to allow for?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: How to Commit trasction(master -details)

    06-04-2007, 8:17 AM
    • Loading...
    • vijaya123
    • Joined on 05-19-2007, 3:10 AM
    • Posts 6

    master and detail data will be in the  one - many

    i will enter customer detail in master and list of item purchased in detail through grid view

     

    thank you

    vijaya

     

  • Re: How to Commit trasction(master -details)

    06-04-2007, 12:46 PM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 6,476

    Can the master be written before the detail?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: How to write Commit trasction

    06-05-2007, 3:33 AM
    Answer

    Hi,

    I would suggest all the transactions implemented in DAL. In your BLL object operations, you can add a flag to indicate using Transaction. Then in the DAL, it will start a transaction and enroll all the insert operations in this transaction.

    HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

     

    Sincerely,
    Kevin Yu
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: How Commit trasction in master detail

    06-06-2007, 2:49 AM
    • Loading...
    • vijaya123
    • Joined on 05-19-2007, 3:10 AM
    • Posts 6

    i did not get how to perfom commit transaction in master detail when master and detail uses BLL+ DAL

     

    thank you

    vijaya 

Page 1 of 1 (11 items)
Microsoft Communities
Page view counter