如何使用C#删除行后重新排列MS-Access中的自动编号 [英] How To Rearrange The Auto Number In MS-Access After Deleting A Row Using C#

查看:171
本文介绍了如何使用C#删除行后重新排列MS-Access中的自动编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MS-Access数据库。我已经拿到S.No.作为自动编号数据类型..

我已插入一些数据..现在每行都会按顺序生成自动编号例如:1,2,3依此类推...现在如果我删除所有行中间的一行(记录),假设我有1 2 3 4 5 6 7 8 9 10记录在那里。如果我删除了第5个记录,那么在S.No.列(自动编号数据类型)仅显示1 2 3 4 6 7 8 9 10缺少已删除的编号。



现在我的问题是我们可以重新排列S.没有。使用C#Windows应用程序在MS-Access数据库中的列顺序为1 2 3 4 5 6 7 8 9.



请帮助我..

I Have A Database Of MS-Access.In That I Have Taken S.No. As Auto Number DataType..
I Had Inserted Some Data..Now For Each Row An Auto Number Is Generated In A Sequential Order For Example: 1,2,3 To so on...Now If I Delete A Row Which Is In The Middle Of All The Rows(Record), For Suppose I Have 1 2 3 4 5 6 7 8 9 10 Records Are There. If I Deleted 5th Record,Then In The S.No. Column(AutoNumber DataType) It Shows Only 1 2 3 4 6 7 8 9 10 by Missing The Deleted Number.

Now My Question Is That Can We Rearrange The S.No. Column Order As 1 2 3 4 5 6 7 8 9 in The MS- Access Database Using C# Windows Application.

pls Help Me..

推荐答案

你可以,但这是一个非常糟糕的主意。问题是双重的:

首先,行号是一个标识 - 它使行唯一,并且不能重复。其他表格使用它来明确标识行,并将发票(在一个表格中)上的项目与标识另一个中的交易的特定发票绑定。如果您对发票表中的行号重新排序,则还必须在发票项目表中重新订购相应的号码,否则客户将收到他未订购的物品的费用。

其次,有一个合理的可能性,一个用户不会使用它:如果两个用户同时删除两个不同的行,会发生什么?可能出错的排列是巨大的,并且可能导致严重的不可预测的错误。
You can, but it is a very bad idea. The problem is two-fold:
Firstly, the "row number" is an identity - it makes the row unique, and cannot be repeated. It is used by other tables to identify the row specifically, and to tie for example the items on an invoice (in one table) to the specific invoice identifying the transaction in another. If you reorder the "row numbers" in the invoice table, you must also re-order the corresponding numbers in the invoice items table, or a customer will get billed for items he did not order.
Secondly, there is a reasonable chance that this will not be used by just one user: what happens if two users delete two different rows at the same time? The permutations of what could go wrong are enormous, and can cause seriously unpredictable bugs.


这篇关于如何使用C#删除行后重新排列MS-Access中的自动编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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