SQL CE如何忽略重复插入 [英] SQL CE How to ignore duplicate insert

查看:55
本文介绍了SQL CE如何忽略重复插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  SqlCeCommand命令=新SqlCeCommand(@" INSERT INTO fpl_table 

              &NBSP ;           (FLIGHT_ID,BPN_TIME,BPX_TIME,DAY_NB) 

                            VALUES(@FLIGHT_ID,@ BPN_TIME,@BPX_TIME,@DAY_NB)

                            ON DUBLICATE UPDATE FLIGHT_ID = @FLIGHT_ID,BPN_TIME = @ BPN_TIME,BPX_TIME = @ BPX_TIME,DAY_NB = @ DAY_NB"

&NBSP ;                                ,连接);
$


            command.Parameters.AddWithValue(" FLIGHT_ID",format);

            command.Parameters.AddWithValue(" BPN_TIME",format1);

            command.Parameters.AddWithValue(" BPX_TIME",format2);

            command.Parameters.AddWithValue(QUOT; DAY_NB" ;, format3);

  SqlCeCommand command = new SqlCeCommand(@"INSERT INTO fpl_table 
                                                    (FLIGHT_ID, BPN_TIME, BPX_TIME, DAY_NB) 
                                                    VALUES (@FLIGHT_ID, @BPN_TIME, @BPX_TIME, @DAY_NB)
                                                    ON DUBLICATE UPDATE FLIGHT_ID = @FLIGHT_ID, BPN_TIME=@BPN_TIME,BPX_TIME=@BPX_TIME,DAY_NB=@DAY_NB"
                                                    ,connection);

            command.Parameters.AddWithValue("FLIGHT_ID", format);
            command.Parameters.AddWithValue("BPN_TIME", format1);
            command.Parameters.AddWithValue("BPX_TIME", format2);
            command.Parameters.AddWithValue("DAY_NB", format3);

大家好

伊夫与插入4个值到列中得到了问题!。我想防止将4个现有列插入数据库,我不能将它们设置为唯一,因为同一列可以插入其他1,2或3列,我只想防止只有4个现有列
insert。

Ive got the problem with inserting 4 values into columns. I wanna prevent inserting 4 existing columns into database, i cant set them unique, cause the same column can be inserted with other 1,2 or 3 columns, i just wanna prevent only 4 existing columns insert.

推荐答案

我不确定我是否理解这个问题。您可以为多个列创建唯一索引,在您的情况下为四个。基本上只有四列一起是独一无二的,如果其中任何一个重复,都无关紧要。
I'm not sure if I understand the question. You can create a unique index for multiple columns, four in your case. Basically only the four columns together would be unique and it would not matter if any one of them was duplicated.


这篇关于SQL CE如何忽略重复插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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