你是如何产生主键的? 冲突? - - Nicholas Paldino [.NET / C#MVP] - mv*@spam.guard.caspershouse.com " BLUE" < bluewrote in message news:O8 ************** @ TK2MSFTNGP03.phx.gbl ...Luigi,How is it that you are generating your primary key where you can getconflicts?--- Nicholas Paldino [.NET/C# MVP]- mv*@spam.guard.caspershouse.com"BLUE" <bluewrote in message news:O8**************@TK2MSFTNGP03.phx.gbl... >不过,就个人而言,我会在 System.Transactions命名空间中使用TransactionScope类,并将你的调用包装在那个>Personally, though, I would use the TransactionScope class in theSystem.Transactions namespace, and wrap your calls to theDbProviderFactory in that DbProviderFactory中br /> 非常感谢你! 我不知道它但在5分钟内我看到它很容易使用和 功能强大。 我会使用交易,所以如果有问题我可以回滚所有插页 并更新我''已在事务范围内完成。 我想创建一个字符串,只有当 不存在时才将其插入到DB的记录中:如果是现在我想生成另一个字符串并重试 等等(这是当多个用户插入我的 表并且我需要检查主键是唯一的情况在插入之前和 不等待最终的异常)。 我可以循环直到插入顺利或有更好的方法(最好 练习)? 谢谢, Luigi。Thank you very very much!!!I didn''t know about it but in 5 minutes I''ve seen it''s easy to use andpowerful.I''ll use transactions so if there are problems I can roll back all insertsand update I''ve done inside a transaction scope.I want to create a string and insert it into a record of the DB only ifnot present: if it is present I want to generate another string and retryand so on (this is the scenario when multiple users are inserting into mytables and I need to check primary key is unique before inserting it andnot wait the eventual exception).Can I loop until an insertion goes well or there is a better way (bestpractice)?Thanks,Luigi. 这篇关于DbProviderFactory和交易。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-22 14:18