通过队列生成代码(多CPU编程) [英] Generate Code By a Queue (Multi Cpu Programing)
问题描述
我在Vb.Net中有一个应用程序。我正在Microsoft Visual Studio 2008,VB.NET,Sql Server 2005,Crystal Report上开发此应用程序。
该申请表有登记表。现在我的问题是
此应用程序安装在网络中的5台不同计算机上。平均时间所有5个用户
都是开放注册表单然后他们同时点击保存按钮。我有一个表注册,并有一个列(代码)是主键。每当他们想要保存记录时,只有一个用户可以保存记录。由于主键冲突错误,所有4个用户都回滚事务。因此我想在队列的基础上生成代码..用户可以等待获取该记录的唯一代码,我不希望用户请求回滚...
I have a Application In Vb.Net .I am Developing This Application on Microsoft Visual Studio 2008 , VB.NET, Sql Server 2005 , Crystal Report.
And That Application Have Registration Form . Now My Question Is
This Application is Installed On 5 different Computer In a Network . At the Mean time all 5 users
are Open Registration form Then They click on Save button on same time . I Have a table registration , and that has a column (code) that is primary key. whenever they want to save the record only one user can get save the record . all 4 users are rollback the transaction because of primary key violation error. Therefor i want to generate code on a queue basis .. where user can wait to get a Unique Code of that Record and i dont want to users request to rollback ...
推荐答案
Mohammad,
INSERT
在表格中创建行/记录时,需要主键;尚未使用的。这意味着,你需要一个共同的过程;它可以在要插入的行中的键之前查找要使用的新键。或者你需要一把钥匙;这是由数据库生成的,应用IDENTITY列。这意味着,将有5行。
更新
更新行时;最后一次用户更新获胜。你无能为力。但是,这不应该创建主键违规。
:)
Mohammad,
INSERT
When you create a row/record in a table, you need a primary key; which has not been used, yet. this means, you need a common process; which can lookup for a new key to use before the key in the row to insert. Or you need a key; which is generated by the database, applying a IDENTITY column. This means, there will be 5 rows.
UPDATE
When you update a row; the last user update wins. There's not much else you can do. However, this shouldn't create a primary key violation.
:)
这篇关于通过队列生成代码(多CPU编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!