Inserting new rows in distinct tables in a database using generated DataSet , csharp , ms sequel server 2008 Maastricht, Netherlands
  • 11 years ago
    Hi all, I'm currently writing C# code to populate a MS Sequel Server 2008 DataBase. To accomplish this, I have used the Visual Studio db-tool to automatically generate the DataSet containing many tables and relations between the tables. I am able to create new rows and update the tables, but I've got a problem with the adaptation of the relationships between the in memory DataSet and the database: When I'm adding a new row to the DataSet, automatically a primary key is generated using the AutoIncrement property. However the in memory DataSet may not generate the appropriate key according to the database (while the program is working on the in memory DataSet, the db may have already been updated and the assigned key may already been used.). This also means that foreign relations from other tables may point to the wrong row. Is there somehow a method to abstract the relations between rows of different tables so that the primary and foreign keys are translated (or assigned) by an adapter, when the updates are committed to the database?

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell