开发者

copy database row with all dependency with others Tables

Hi all I have below mentioned Tables and every Table ID is auto incremented in DB (I can't change this property).

    Box_Table
Id  Name    Cost
 1  Box1    100
 2  Box2    175

    Fruit_Table  
Id  Name    Cost
1   Apple   100
2   Orange  75
3   Bannana 25


    Box_Fruit_Table 
Id  Box_Id  Fruit_Id
1      1      2
2      1      3
3      2      1
4      2      2

I am trying to duplicate ROW of Table Box_Table.

I am trying this in WPF using DataSet by adding one Row to the DataSet and copying the content of duplicating ROW except ID and doing commiting. After getting duplicated ID have to update the Box_Fruit_Table.

Problem I am facing is: As ID is autoincrement in DB, only after commit I will get 开发者_JS百科the generated ID. Because of this I am not able to update the BOX_FRUIT_TABLE for duplicated ROW.


do following steps

1- Save in the parent table 'Box_Table'

2- Get the latest id generated

3- Update the Box_Fruit_Table with this new id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜