如何在Ms Access(Vb.Net Oriented)中重新排列Id(自动编号数据类型) [英] How Do I Rearrange The Id(Auto Number Datatype) In Ms Access (Vb.Net Oriented)

查看:86
本文介绍了如何在Ms Access(Vb.Net Oriented)中重新排列Id(自动编号数据类型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai朋友,

我设计了一个vb .net表单,ms作为Backend访问。



第一期:



ID CODE

1 a1

2 b1

3 c1



这些是我的字段。



如果我删除记录2 b1,那么我的桌子就像这样:



ID CODE

1 a1

3 c1



所以表看起来缺少2个ID。



第二个问题:

如果我删除所有记录,那么我的表用id开头'4'



删除所有记录后,当我插入一条记录然后我的桌子看起来像这样。



ID CODE

4 a1

5 b1

6 c1



这里我需要从1开始id



请帮帮我朋友。



问候,

Sissy ram

Hai friends,
I have designed a vb .net form with ms access as Backend.

First Issue:

ID CODE
1 a1
2 b1
3 c1

These are my fields.

If i delete a record "2 b1" then my table became like this:

ID CODE
1 a1
3 c1

So the table looks missing 2 id .

Second Issue:
If i delete all the records, then my table begans with id '4'

after deleting all the records, when i insert a record then my table looks like this.

ID CODE
4 a1
5 b1
6 c1

Here i need to began id from 1

Please help me friends.

regards,
Sissy ram

推荐答案

你可以这样做:但是这是一个非常非常糟糕的主意。自动编号字段的想法是数据库负责确保不重复值,因此您可以将它们用作其他表中行的索引:如果您开始对它们重新编号,那么您将面临其他风险表格数据没有在正确的时间更新,错误的数据与错误的行相关联:然后您的客户开始抱怨(大多数时候)他们的发票上有他们没有订购或收到的物品!



如果你想要一个随着数据库中的行数而变化的行号,那么请看这里有几个想法:http://support.microsoft.com/kb/186133/en-us [ ^ ]
You can do it: but it's a very, very bad idea. The idea of an automatically numbered field is that the database takes care of ensuring that values aren't duplicated, so you can use them as an index to the row from other tables: if you start renumbering them, then you run the risk that other table data is not updated at the right time, and the wrong data becomes associated with the wrong row: then your customers start complaining (vociferously, most of the time) that their invoice has items they did not order, or receive!

If you want a "row number" that changes with the number of rows in the database, then see here for a couple of ideas: http://support.microsoft.com/kb/186133/en-us[^]


这篇关于如何在Ms Access(Vb.Net Oriented)中重新排列Id(自动编号数据类型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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