在vb.net中使用linq插入之前如何检查数据库中的重复记录 [英] How to check duplicate records in the database before inserting using linq in vb.net

查看:254
本文介绍了在vb.net中使用linq插入之前如何检查数据库中的重复记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vb.net中使用linq插入之前如何检查数据库中的重复记录

例如,我有一个general_categories表,由cat_id和类别组成

当我单击保存到vb.net"时,将弹出消息,提示它们是重复的

当您要保存的文件存在时发现记录..........

How to check duplicate records in the database before inserting using linq in vb.net

for example I have a table of general_categories, consists of cat_id and categories

when i click save to vb.net there will pop up message says that their is duplicate

records found when the file you want to save is existing..........

推荐答案

我认为这是您正在尝试的非常基本的工程解决方案.

阅读所有链接,因为我发现这对理解LinQ的基本功能非常有帮助.

http://msdn.microsoft.com/en-us/vstudio/bb688088.aspx [ ^ ]


除此之外,我想以代码形式而是算法形式为您的问题提供解决方案.
1)连接数据库
2)使用该连接运行LinQ Query
3)声明一个变量,该变量将为结果存储是/否
4)编写SELECT查询以查找表中的数据如果存在查询将返回YES,否则返回
5)利用此条件来处理进一步的请求.


希望这会有所帮助,如果是,那么请接受并投票答复.任何对此的任何疑问/问题都将受到欢迎.

谢谢&问候
RDBurmon.Sr.软件工程师
I think this is very basic engineering solution that your are trying .

Read this all link as I found this to be very helpful to understand basic functionality of LinQ .

http://msdn.microsoft.com/en-us/vstudio/bb688088.aspx[^]


Apart from this I would like to give solution for your issue not in the form of code but in the form of algorithm.
1) Connect the database
2) Use that connection to run LinQ Query
3) Declare one variable which will store YES/NO for result
4) Write SELECT query to find out the data in table If exists query will return YES otherwise NO
5) Make use of this condition to process further request.


Hope this helps , If yes then plz accept and vote the answer. Any queries / questions on this are always welcome.

Thanks & Regards
RDBurmon.Sr.Software Engineer


这篇关于在vb.net中使用linq插入之前如何检查数据库中的重复记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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