I can not figure out how to add data. There are two datagridview grids

enter image description here

and there are two tables with links in the database.

enter image description here

I save the changes like this:

 this.tableataptor.UpdateAll(this.dataset); 

So, when adding data to the first table and the second one at the same time, it gives an error message, in which it swears at the connection between them. If you save the data first to the first table, the data is saved, and then when you select the row from the first grid, add data to the second grid, then they are saved.

How to save changes to the database?

  • Nick Fast code can show. - Ismoil Muhammadiev
  • Can use TabControl for different datagridview - Ismoil Muhammadiev
  • The insert update delete code is generated on the machine when added to the form. TabControl is not an option. then in the second tab again there will be two grids, select a row in one grid and add data to another. But again, it is necessary to have data in the first grid - Nick Fast

1 answer 1

Error just in connection. You did not have time to update the first table, and you are trying to update the second one related to it. You must first update one table in the code, and then the second.

  • but how to do it? if i do this: htis.registrtableadaptor.Update (dataset) and then this.probatableadaptor.Update (dataset) then the error is the same. Logically, yes, I have to update the first registration table and then update the second (child) table - Nick Fast