此操作的逻辑

编程入门 行业动态 更新时间:2024-10-28 02:33:50
本文介绍了此操作的逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的数据库中有一张表说Tab1(col1,col2) 条目(对应条目) Col1 col2 a - sep1 b - sep2 c - sep3 d - sep4 e - sep5 现在如果我上传新条目如 Col1 col2 a - sep3 b - sep2 所以如果这个新条目没有退出,那么它只是插入这些新条目,否则更新它。 我想要它的C#逻辑, 我试过这个,但它没有工作

I have a table in my database say Tab1(col1, col2) entries are(corresponding entries) Col1 col2 a - sep1 b - sep2 c - sep3 d - sep4 e - sep5 now if i upload new entries like Col1 col2 a - sep3 b - sep2 so if this new entries does not exits then it simply INSERT these new entries else update it. I want C# logic for it, I tried this but its not working

if (isSuccess) { if (!(isWellIdExists(impexp.WellId) || isUploadedDateExists(impexp.UploadedDate))) { int result = ExecuteQuery("InsertImpExpData", SerialIDParameter, WellIdParameter, DateRecievedParameter, DueDateParameter, UploadedFootageParameter, UploadedDateParameter, PriorityParameter, RemarkParameter); } } else { int result = ExecuteQuery("UpdateImpExp"); } return isSuccess;

删除了SHOUTING,添加了代码块 - OriginalGriff [/ edit]

[edit]SHOUTING removed, Code block added - OriginalGriff[/edit]

推荐答案

首先,你应该使用单一检查... 使用您提供的代码,您将获得 适用于isWellIdExists和 适用于isUploadedDateExists 对于9月3日你的例子 因为或OR条件然后否定它会让你失误=>更新时应该插入 z Sep3将为您提供一个真实的(isUploadedDateExists)并且您将再次获得更新 类似的逻辑适用于所有其他组合,如果id和日期从未进入yorr系统,你只会得到插入 正确实施应该是 First of all, you should use single check for both... With the code you provided you will have True for isWellIdExists and True for isUploadedDateExists for a Sep3 as per your example because or OR condition and then negating it will get you false => Update when you should get Insert z Sep3 will get you one true (isUploadedDateExists) and you will get update again Similar logic goes for all other combinations, you'll only get insert if id AND date never entered into yorr system Correct implementation should be if (ExistsWellID_And_UpdateDate(id, date)) { // update } else { // insert }

这当然取决于你的功能正在做他们的名字所暗示的......

This is of course conditional on your function doing what their names imply...

if (isWellIdExists(impexp.WellId) && isUploadedDateExists(impexp.UploadedDate)) { int result = ExecuteQuery("UpdateImpExp"); } else { int result = ExecuteQuery("InsertImpExpData", SerialIDParameter, WellIdParameter, DateRecievedParameter, DueDateParameter, UploadedFootageParameter, UploadedDateParameter, PriorityParameter, RemarkParameter); }

更多推荐

此操作的逻辑

本文发布于:2023-07-31 15:36:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1259971.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:逻辑   操作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!