在Db中添加重复值 [英] Adding duplicate values in Db

查看:100
本文介绍了在Db中添加重复值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我有一个带有保存,删除和复制到
选项的网格视图
复制到-表示在单击一行时将值填充到另一页,我们可以修改一些值并将新记录保存到db

Benifit不需要输入所有值

缺点是,如果我们不做任何更改,然后单击保存按钮,它将保存同一条记录,因此网格将两次将同一条记录使用不同的ID放置两次.这样我们就可以解决...


任何帮助将不胜感激

Chinnu

Hi friends

I hav a grid view with options save, delete and copy to

copy to - means while clicking a row it populate values to another page and we can modify some values and can save a new record to db

Benifit is no need to enter all values

disadvantage is if we dont change anything and click on the save button iit wil save the same record, so the grid wil dipslay same record twice with different ID''s . so we can handle this...


Any help wil be appreciated

Chinnu

推荐答案

您可以使用一个开关,该开关在发生某些更改时会翻转,或者在保存时在数据库上运行SELECT查询以查看是否存在完全匹配.

有关数据库模式(和服务器类型)的更多信息将使提供更好的示例变得更加容易.
You could either have a switch that flips when something''s changed, or run a SELECT query on the database when saving to see if there''s an exact match.

More information on the database schema (and server type) would make it easier to provide a better example.




在这里'为此提供了一些链接,因此通过它您可以了解如何做

http://msdn.microsoft.com/en-us/library/aa933214%28v = sql.80%29.aspx

在上面的链接中,我们如何在sql中使用if-else.

通过这种方式,您可以进行类似
的查询
if((从您的表名中选择ID,其中name =''''和pwd =''''和.....)> 0)
开始
没有操作
结束
其他
开始
插入yourtablename值(``name'',``pwd''...)
结束

这是我的主意,但您也可以在C#中进行比较.

我希望你能理解我说的话


最好的
Hi,

Here ''m providing some link for it,so go through it you can get idea how to do

http://msdn.microsoft.com/en-us/library/aa933214%28v=sql.80%29.aspx

In the above link how we use if-else in sql.

By means you can make query like

if((select id from yourtablename where name='''' and pwd='''' and .....)>0)
begin
no operations
end
else
begin
insert into yourtablename values (''name'',''pwd''...)
end

This is my idea but you can compare in C# also.

I hope you understood What I said


All the Best


这篇关于在Db中添加重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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