在lan上划分序列号 [英] dividing serial number on lan

查看:127
本文介绍了在lan上划分序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,我用c#和sql服务器开发了一个asp.net项目。

在我的项目中,我使用自动生成的数字进行交易,但单项工作正常系统,但是当我在iis上托管并通过本地网络访问多个系统时,每个系统都会出现相同的serail编号,我很困惑如何阻止已经使用其他系统的编号,



可以有人给出建议,让一个号码不应该进入另一个必须自动生成的系统。



谢谢。

解决方案

我只是在这里猜测 - 因为你没有展示我们所能做的任何代码 - 但我可以从你的问题中推断出两件事: br />
1)您正在使用SQL标识字段来创建ID号。

2)您可能正在获取当前的MAX ID值并自行添加一个以生成下一个 ID值,稍后再使用。



这不起作用:你根本不能预测下一个值,因为(正如你所发现的)只要你有一个以上的系统预测值,它们都开始复制,整个事情都会崩溃。

你只能确定新记录的创建价值:你不能在任何其他时间假设一个值。 / blockquote>

继OriginalGriff的解决方案1之后,@@@ IDENTITY与SCOPE_IDENTITY()对IDENT_CURRENT的以下链接可能有所帮助:



@@ IDENTITY vs SCOPE_IDENTITY()vs IDENT_CURRENT [ ^ ]


< blockquote>我能理解你的问题。我有一些建议可以解决这个问题。



1.您可以使用标识栏生成自动编号。

2.如果是不是你的解决方案,如果你想自己生成自定义自动编号,你可以建立一个算法,可能会产生一个唯一的数字(你可以用最后一个数字增加一个新的数字),然后插入最后生成的数字进入数据库表。每当您需要自动生成的号码时,您只会从数据库表中选择号码,然后创建一个自动号码,它将取代先前的号码来解决您的问题。





-Thanks,

Mamun


hello friends, i had developed an asp.net project using c# and sql server.
In my project in many of forms i have used auto generated number for transactions, it is working fine on single system, but when i host it on iis and access on more than one system through local network, the same serail number is coming on every system, i'm confused how to block a number which is already using another system,

can somebody give suggestions to get one number should not come in another system which has to be generated automatically.

Thanks.

解决方案

I'm just guessing here - since you haven't shown any code that all we can do - but I can infer two things from your question:
1) You are using an SQL Identity field to create the ID number.
2) You are probably getting the current MAX ID value and adding one yourself to generate the "next" ID value, and using that later.

That doesn't work: you cannot "predict" the next value at all, because (as you have found) as soon as you have more than one system "predicting" values, they all start to duplicate and the whole things falls over.
You can only ever be sure of the value immediately the new record has been created: you cannot assume a value at any other time.


Further to Solution 1 by OriginalGriff, the following link on @@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT may help:

@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT[^]


I can understand your problem. I have some suggestions for to overcome this problem.

1. You can use identity column to generate auto number.
2. If that is not your solution and if you want to generate custom auto number by your own, you can then build a algorithm which will possibly generate a unique number (you can increase with last number to get a new number ) and then insert the last generated number into a database table. Every time when you require the auto generated number you will only pick the number from the database table and then create a auto number which will replace the earlier number that will solve you problem.


-Thanks,
Mamun


这篇关于在lan上划分序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆