删除过程后重新排序主键 [英] reordering primary key after deleting process

查看:93
本文介绍了删除过程后重新排序主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

当我从数据库中删除任何值时,我想再次对主键重新排序..

我该怎么做 ?

例如

ID NAME
1约翰
2 SEVINC
3 ALI
4 OSMAN
5 FEYZA
6 CIHAT

为了实例化,如果我从数据库中删除第四人奥斯曼,则在我的访问数据库中,它将转换为

ID NAME
1约翰
2 SEVINC
3 ALI
5 FEYZA
6 CIHAT

但是我想做新订单,如

ID NAME
1约翰
2 SEVINC
3 ALI
4 FEYZA
5 CIHAT

我该怎么办?

hi guys,

When i delete any value from database , i want to reorder the primary key again ..

how can i do it ?

for example

ID NAME
1 JOHN
2 SEVINC
3 ALI
4 OSMAN
5 FEYZA
6 CIHAT

FOR INSTANCE , if i delete 4th person Osman from database , in my access database , it converts

ID NAME
1 JOHN
2 SEVINC
3 ALI
5 FEYZA
6 CIHAT

BUT I WANA DO NEW ORDER LIKE

ID NAME
1 JOHN
2 SEVINC
3 ALI
4 FEYZA
5 CIHAT

HOW CAN I DO IT ?

推荐答案

主键用于将表连接在一起并建立索引,而不是用于人类.重新排列主键列可能会孤立数据,并严重破坏您的查询.

在表中添加另一列,然后将其重新排序(向用户显示该列而不是主键).
Primary keys are meant to be used for joining tables together and indexing, they are not meant to be used for human usage. Reordering primary key columns could orphan data and wreck havoc to your queries.

Add another column to your table and reorder that column to your will (show that column to your user instead of the primary key).


您好,

无需重新排列主键,ListBox具有两个属性(值和文本),将主键字段(ID)绑定到value属性,并在删除记录后重新绑定网格.

this.listBox1.DataSource = listToBind;
this.listBox1.DisplayMember =文本";
this.listBox1.ValueMember ="Id";

您可以使用属性来检索选定的值.

ListBox1.SelectedValue

希望对您有帮助.

谢谢!!!
Hi,

No need to rearrange the Primary key, ListBox has two properties( value and text), bind the primary key field(ID) to value property and rebind the grid after deleting the records.

this.listBox1.DataSource = listToBind ;
this.listBox1.DisplayMember = "Text";
this.listBox1.ValueMember = "Id";

You can retrieve the selected value using the property.

ListBox1.SelectedValue

Hope this will help you.

Thanks!!!


这篇关于删除过程后重新排序主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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