Results 1 to 3 of 3

Thread: Data tier development issue in 3-tier architecture in Vb.Net?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Baton Rouge, Louisiana.
    Posts
    109

    Question Data tier development issue in 3-tier architecture in Vb.Net?

    Hii to All,


    My question is


    Databse: MS Access
    Language is : VB .Net

    I have two tables(Table 1 and table 2) related through primary key. Two classes, class 1 works with table 1 and class2 works with table 2.

    So, what i am doing is call method in first class perfom "Insert " on table 1, get primary key of table 1, then call method in second class which works with tabl2 and "Insert" record record in table 2 with Primary key. (Which is foriggn key for table 2)

    If Second "insert" failed by any chance, i am not able to rollback first "Insert" performed table 1 as both are in different classes.

    My question is How to Develop classes or methods in data tier which only works with database.? and where i can able to Roll Back first "Inert" in case if second "Insert" failed. ?

    Please give your feedback ... or any reference.....

    Thanks in advance...

    HDave
    ~~~......Hope never dies. one has to work for it to make it reality.......~~~

  2. #2
    Addicted Member
    Join Date
    Sep 2004
    Location
    Brooklyn
    Posts
    147
    You need to nest the inserts.

    Do the insert into table1, get the primary key, then use a Try ... Catch block to attempt the insert into table2. If that fails for any reason, rollback the insert to table1, if it succeeds, then commit the changes to table1.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Baton Rouge, Louisiana.
    Posts
    109
    Thanks...

    Both "INSERT" are in different classes. As each class attached with single table. So, i am calling first "INSERT" in one class and then get primary key and call method in another class to Perform Second "INSERT".

    As per your solution one class interect with both tables and perform "INSERT". Right?


    Actually i have hierarchy of objects. I have to go from root to leaf node to store their values in database. Primary key of from first "INSERT" will be used in all other "INSERT" as all obejects are related in hirarchy with realtion.

    What should i do to achive this?

    Please do reply...I am really confused what to do?

    HDave
    ~~~......Hope never dies. one has to work for it to make it reality.......~~~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width