代码必须编辑单元格,但它编辑重复项 [英] Code must edit cell but it edits an duplicates

查看:102
本文介绍了代码必须编辑单元格,但它编辑重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码不仅可以编辑单元格并对其进行编辑,还可以重复
我找不到问题,请帮帮我

This code is not only edits cells value its edits and duplicate also
I cannot find problem please help me

internal static void EditProduct(string txtBarCode, string txtArtNumber, string txtProductName, string txtPrice, string txtComment, decimal NumericUpDown1, string PriceWithOutAWD, string txtSelfPrice)
       {
           SqlConnection con = new SqlConnection(ConnectionString);
           SqlCommand cmd = new SqlCommand("UPDATE Products SET BarCode = @BarCode, ArtNumber = @ArtNumber, ProductName = @ProductName, Price = @Price, SelfPrice = @SelfPrice, PriceWithOutAWD = @PriceWithOutAWD, UnitsInStock = @UnitsInStock, Comment = @Comment WHERE BarCode = @bc AND ArtNumber = @an ", con);


           cmd.Parameters.Add(new SqlParameter("@BarCode", txtBarCode));
           cmd.Parameters.Add(new SqlParameter("@ArtNumber", txtArtNumber));
           cmd.Parameters.Add(new SqlParameter("@ProductName", txtProductName));
           cmd.Parameters.Add(new SqlParameter("@Price", txtPrice));
           cmd.Parameters.Add(new SqlParameter("@SelfPrice", txtSelfPrice));
           cmd.Parameters.Add(new SqlParameter("@PriceWithOutAWD", PriceWithOutAWD));
           cmd.Parameters.Add(new SqlParameter("@UnitsInStock", NumericUpDown1));
           cmd.Parameters.Add(new SqlParameter("@Comment", txtComment));
           cmd.Parameters.Add(new SqlParameter("@bc", txtBarCode));
           cmd.Parameters.Add(new SqlParameter("@an", txtArtNumber));
           try
           {
               con.Open();
               cmd.ExecuteNonQuery();
           }
           finally
           {
               con.Close();
           }
       }

推荐答案

是否执行条形码& artnumber集体使唱片独一无二吗?
还是重复项也可以具有相同的值?

根据您的查询,给定记录的编辑可以更新重复记录的唯一原因是当您具有与原始记录相同的条形码+艺术编号"组合时.
Does barcode & artnumber collectively make the record unique?
Or duplicates too can have same values for it?

Based on your query, only reason why an edit of a given record can update a duplicate one is when you have same ''barcode + artnumber'' combination for them as original has.


这篇关于代码必须编辑单元格,但它编辑重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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