Community discussion forum

Inserting new rows in distinct tables in a database using generated DataSet

  • 8 months 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 was edited on 27/03/2009 14:32:38 Report abuse

Post a reply

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

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

Want to stay in touch with what's going on? Follow us on twitter!