How To Save Data In Different Tables C# [Resolved]

Posted by Kasani007 under C# on 8/2/2016 | Points: 10 | Views : 1513 | Status : [Member] | Replies : 5
I Have 3 Tables

1) Employee_Table

2) Insurance_Table

3) Employee_Insurance_Table



Employee_Table And Insurance_Table Have No Relation And 

Employee_Insurance_Table Have Foreign Key Relation With Employee_Table And Insurance_Table 's Primary Keys



How Can I Save Data In C# Having Domain Object and Business Object ?




Responses

Posted by: Rajnilari2015 on: 8/3/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kasani007 Sir,

First you insert into Employee_Table and Insurance_Table. Then write a store procedure and inside that use Merge Statement ( https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx ) and ensure that while inserting into Employee_Insurance_Table table, both the PK's of the tables are present.

Hope that helps.

--
Thanks & Regards,
RNA Team

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 8/2/2016 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

Step1:

First Design UI Entry Page for Employee_Table ex:

Name,Empno,Gender and etc if you want

then another page design for Employee_Insurance_Table

then put dropdown list for get employee table primary key so

design ddl control loaded employee name set empid primary key in datavalue field

after finally inserted to transaction table this Employee_Insurance_Table then get ddl id stored to this table

Employee_Insurance_Table here now inserted in your primary key thats it.





Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 8/2/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
@ Kasani007 Sir,
Employee_Insurance_Table is known as junction table which gets involve while two entities have multiple relationships between them.
Store the PK value of both Employee_Table And Insurance_Table in that junction table.

--
Thanks & Regards,
RNA Team

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kasani007 on: 8/2/2016 [Member] Starter | Points: 25

Up
0
Down
thanQ Rajnilari for your response,

How To Store Both Employee_Table And Insurance_Table primary keys values in Junction Table..

please let me know your valuable Information.

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response