Click here to Skip to main content
15,903,770 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I’m a beginner in C#, so I would to be patient with me please.
I have two connected tables, I filled the first one (with primary key) with data as usual by adding textboxes to a form and so on.. .I have no problem with it, but the problem is with the second one –the child- (of Foreign key) which is connected to gridview.How can I fill the foreign key field’s column in the data grid, in other words , how can I transfer the primary key value from the 1rst table in the form1 to the foreign key field's column of gridview in the 2nd form.
Any help would be greatly appreciated.
Posted

1 solution

Hi,

For this you'll have to insert values in both tables

do this

1: insert values in table containing Primary Key
2: Retrieve data that you just inserted(by select query for eg select * from table name where anyfieldonform = 'value')

3: insert the required data into the table containing foreign key
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900