记录在sql server中重复 [英] records are duplicated in sql server

查看:74
本文介绍了记录在sql server中重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发发票打印应用程序.
一切工作正常,只是在保存记录时有时会重复记录.
它只会在某些情况下才能正常运行.
我将vb.net用作前端,将sql server 2005用作后端.
.net代码正常.一周内只会发生1次.

如此.告诉我解决方案.我认为这是sql server的问题.
我找不到它.

由于查询在循环中,因此仅在子表中会发生这种情况.

在同一表的主表中仅插入一条记录.

解决方案

只有在插入事件有时触发两次的情况下,这种情况才会发生.
假设您不幸两次单击按钮.

代码段只能使我们清晰.




一件事很清楚,这不是sql server的问题.它可以节省您所提供的东西.重新检查您的代码,并保存您的记录的存储过程.重新检查并重新定义表的键和约束.


实际上,与这里的其他所有人不同,我相信您的问题出在数据库上,这就是原因.
对表的任何插入,特别是包含财务信息的表,都需要得到适当的保护和验证.

在这样的表上插入数据应该始终经过存储过程,以便在数据作为重复数据进入表之前可以被验证为唯一.如果发现试图插入的记录可能重复,则应将其写入可疑记录表,然后可以对其进行手动检查,以便在确实有效的情况下将其转移到适当的位置. br/>
Sandeep的答案是正确的,因为asp.net中存在刷新页面问题,并且可能是潜在问题,但是您永远都不要依赖应用程序的UI部分来保护数据.

I am developing an application of invoice printing.
Everything is working perfectly except that sometimes records are duplicated while saving the records.
it happens only for sometimes otherwise its working perfectly.
I am using vb.net as front end and sql server 2005 as back end.
The .net code is ok . this happens only 1 time within a week.

So pls. tell me the solution. i think its a problem of sql server.
I am not able to find it.

This happens only in the child table, due to the query is in the loop.

Only one record is inserted in the master table for the same table.

解决方案

That can only happen if insertion events is firing twice sometime.

Suppose you may have clicked button twice unfortunately.

Code snippets can only give us clarity. if you want you can.


Hi,

One thing is clear it is not a problem of sql server. Its saves what you are providing. Recheck your code and store procedure that saves your records. Recheck and redefine the keys and constraint of your table.


Actually, unlike everyone else here, I believe your issue is with the database, and here is why.

Any insert to a table, especially tables containing financial information, need to be protected and validated properly.

Inserts on tables like this should always go through a stored procedure so that the data can be validated as unique before it gets into the table as a duplicate. If the record that is trying to get inserted is found to be a potential duplicate, it should get written to a suspect record table which can then be manually reviewed so that if it is indeed valid, it can be transferred to the appropriate place.

Sandeep''s answer is correct in that there is a refresh page issue in asp.net and that it could be a potential issue, but you should never, ever rely on the UI portion of an application to protect your data.


这篇关于记录在sql server中重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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