Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding Rows and Constraints
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00819978
Message ID:
00820901
Vues:
27
>>The problem is that if you do this with a PK value the Row knows that it's a PK. If you add two records this way you have a PK rule violation because it's not unique. I've tried to work around this a number of ways, but I can't see a good way to do this generically. THe issue for the most part is that this happens in the guts of the generic business object layer. The value will always be assigned before a save, but right at creation and at addition to the rows collection there may be nothing in the row.
>>
>
>Rick:
>
>Can't you do this by assigning negative values that decrease to the primary key field in the datatable? That's how foxpro does it with cursors. I think after a dataadapter.update() the pk fields are set to the server generated values.

Interesting i have to try that, but that's not really an issue for me since I use stored procs to generate the IDs.

I generally need ids for child records etc. and it's just easier to have these values on hand before hand instead of fixing them when the update occurs.




>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/adonetbest.asp
>"Best Practices for Using ADO.NET" see the section on "Avoiding Auto-Increment Value Conflicts"
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform