Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Manual assignment of Primary Key
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00811534
Message ID:
00811708
Vues:
14
The lock is done via a Stored Procedure in SQL Server. It is wrapped around the update statement and is immediately unlocked after a successful lock. This was an option if you didn't want to use Identity.

You can create a custom DataAccess class that contains your Stored Procedure call for the InsertCommand of the DataAdapter used to perform the update. The Developer's Guide has a page called "Creating Custom Data Access Classes" that steps you through the process.

>You shouldn't lock a table or record across multiple SQL calls, that was the Foxpro way of assigning PK. My main question here is which method in the framework can I override so I can call a SP instead of using the CommandBuilder to perform the INSERT.
>
>There is another way I can think of which is retrieve the max PK, then attempt the insert with a try catch block, retry the insert with the next number for a number of times. Again, where should I add this code?
>
>Stephen
>
>
>>How you get at the next primary key is a separate issue from MMF. Some developers us an ID table that contains the next id to use for each table. The table is locked while the next key is extracted to avoid any concurrency issues. If you find the next id from the actual table, you will need to manually deal with concurrency issues.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform