避免在ASP.net中重复插入数据 [英] Avoid Duplication of Data insertion in ASP.net

查看:92
本文介绍了避免在ASP.net中重复插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好帮手,

我正在做ASP.net应用程序.

我有一页要从用户收集数据并将数据保存到数据库中.

当我单击保存按钮时,所有数据都被成功保存,但是当我刷新该页面时,条目被保存了两次.

如何避免在页面刷新上插入重复项.

谢谢.

Hello helpers,

I am Doing ASP.net application.

I have one page on which I am collecting data from user and saving data into database.

When I click on save button all data is successfully saved but when I Refresh that Page the entries are saved twice.

How could I avoid insertion of Duplicate entries on Page Refresh.

Thanks.

推荐答案

最好的方法是在插入数据之前检查数据是否已经在数据库中.

另外,您可以在插入数据后(例如在sessionvariable中)设置标志,并在保存之前(再次)检查该标志.
Best way would be to check if the Data is already in your database before you insert it.

Also you could set a Flag after inserting your data (for example in a sessionvariable) and check for this flag before you save (again).


好问题!得到我的5.

有一种代码为此处的解决方案 [ ^ ]-我还没有尝试过,但是这个主意听起来不错.
Good question! Get''s my 5.

There is a solution with code here[^] - I haven''t tried it, but the idea seems sound.


嗨尼丁·布瓦特:rose :,

:thumbsdown:

1.只要您要插入数据,就可以验证输入数据" a. (脚本通过..(JavaScript或其他任何语言.))

2.每当您要插入数据时,请清除值.

注意:验证是最好的解决方案...
Hi nitin bhoyate :rose:,

:thumbsdown:

1. whenever u will insert the data, then you validate the input data''a. (Script via..(javascript or anything..))

2. whenever u will insert the data then, Clear the values.

Note: validation is the best solution...


这篇关于避免在ASP.net中重复插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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