记录已存在于DataTable中,无需插入 [英] Record already exist in DataTable no need to be inserted
本文介绍了记录已存在于DataTable中,无需插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的数据表
Hi,
This is my DataTable
Id Item_Id
100 1
100 2
这是我的DataTable,我要检查条件.
例如:
再次尝试插入100(id),1(item_Id).数据不必插入.
This is my DataTable here i want to check the condition.
for ex:
again i try to insert 100 (id) ,1(item_Id).Data has not to be inserted.
Id Item_Id
100 1
100 2
100 1 ( not inserted)
谁能帮我解决这个问题...
在此先感谢....
can any one help me to solve this issue...
Thanks in advance....
推荐答案
u没有解释您的表结构.如果Item_Id列是主表或唯一,则您无法再次插入相同的Item_Id.什么错误我们可以解释一下吗?
u did not explain your table structure .if Item_Id column is primary or u unique then u cant insert same Item_Id again .what error u r getting can u explain ?
您可以将Id
和Item_Id
设置为composite key
.如果您尝试插入相同的记录,则SQL Server将不允许插入并给出异常.
谢谢
you can makeId
andItem_Id
as acomposite key
. In case if you try to insert the same records then the SQL Server won''t allow to insert and give Exception.
Thanks
这篇关于记录已存在于DataTable中,无需插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文