在具有新id的表中插入相同的数据 [英] same data inserting in table with new id

查看:95
本文介绍了在具有新id的表中插入相同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i在插入按钮上写了插入查询。

当点击插入按钮时它会在表格中插入数据。

当我再次点击插入按钮时,它会插入带有新ID的相同数据。



i想要数据已经存在于表中,它必须覆盖那些数据。

重复的行不应该在那里。



任何人都可以帮助我。

示例代码将会有所帮助。



感谢和问候

sam.198979

Hi,

i have written insert query on insert button.
when am clicking on insert button it's inserting data in table.
when i click insert button again and again it's inserting same data with new id.

i want if data is already exist in table,it must overwrite the that data.
repeated rows should no be there.

can any one help me.
sample code ll be helpful.

thanks & Regards
sam.198979

推荐答案

一个选项是在用户点击按钮后通过添加以下内容来禁用按钮:



OnClientClick =this.disabled ='true'; return true;



另一种方法是检查相同字段的记录。如果记录已存在,则不要插入数据。
one option is to disable the button once user clicks on button by adding the following:

OnClientClick="this.disabled='true';return true;"

another way is to check for record with same fields. if record already exists then do not insert the data.


您的问题清楚地解释了问题。

Your question is clearly explaining the problem.
sam.198979写道:
sam.198979 wrote:

当我再次点击插入按钮时,它会插入带有新id的相同数据。

when i click insert button again and again it's inserting same data with new id.



插入数据后清除控件/变量。所以,下次它不会插入相同的数据。




Clear the controls/variables after inserting the data. So, next time it won't insert the same data.

sam.198979写道:
sam.198979 wrote:

我想如果数据已经存在于表中,它必须覆盖该数据。

i want if data is already exist in table,it must overwrite the that data.



您应该使用update命令更新数据库中的现有数据。





- Amit


这篇关于在具有新id的表中插入相同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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