如何使桌面应用程序在LAN环境下为多个用户工作 [英] How to Make a Desktop Application work over LAN Environment for Multiple Users

查看:59
本文介绍了如何使桌面应用程序在LAN环境下为多个用户工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经在Vb.net中使用SQL Server作为数据库创建了一个应用程序,该应用程序工作正常
在单台PC上.但是目前,它已安装在具有中央数据库的多台PC上.多个用户正在通过LAN环境使用,并且如果假设他们在同一屏幕上工作并同时保存交易,则交易ID字段将重复.事务ID字段在数据库中设置为varchar(预定义格式,如S000001).

如何解决此问题,因为我是开发的初学者,请提供帮助.

谢谢.

Hi,
I have created an application in Vb.net with SQL Server as Database which works fine
on single PC. But Currently, it is installed on Multiple PCs with a central Database. Multiple users are using over LAN Environment and if suppose they work on the same screen and save a transaction at the same time the Transaction ID Field is duplicated. The Transaction ID Field is set to varchar (predefined format like S000001) in the database.

How to resolve this issue, Please Help as I am a beginner in development.

Thanks.

推荐答案

您需要研究数据库的设计.如果插入记录正在创建重复键,则存在一些严重的问题.短期修复可以使用事务.在SQL级别或代码级别.

此处:
MSDN:开始交易(Transact-SQL) [ SQL Server事务和错误处理 [ MSDN:本地交易 [在ADO.NET中使用事务 [
You need to look into your DB design. If inserting a record is creating a duplicate key, then there is some serious issue. Short term fix can be using Transactions. Either at SQL level or code level.

Here:
MSDN: BEGIN TRANSACTION (Transact-SQL)[^]
SQL Server Transactions and Error Handling[^]

MSDN: Local Transactions[^]
Using Transactions in ADO.NET[^]


此听起来您正在尝试通过代码生成代理密钥.如果是这种情况,请不要这样做.

而是使用数据库创建唯一值,例如
uniqueidentifier [
This sounds like you''re trying to generate a surrogate key by your code. If that''s the case, don''t do it.

Instead use the database to create a unique value, for example uniqueidentifier[^].

Also if not already done so, you should define this column as the primary or secondary key.


这篇关于如何使桌面应用程序在LAN环境下为多个用户工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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