开发者

How can I add 2 autonumber columns in MS Access

开发者 https://www.devze.com 2023-03-22 10:53 出处:网络
I am coding a webpage with ASP .NET C# I need to add 2 autonumber fields in MS Access but it don\'t let me do it. I did like this:

I am coding a webpage with ASP .NET C#

I need to add 2 autonumber fields in MS Access but it don't let me do it. I did like this:

field size = replication ID
Sequential= yes, without replication

But my column (it calls unique_id) had a value like this ={BBEB19C8-9C6D-4A1D-B966-A409A849D417}. As a result, I want to add a second autonumber field to my MS Access database. How 开发者_StackOverflow中文版can I do this?


A "replication ID" is a GUID. It has to be in order for any form of replication to work.

Also, you can't have 2 auto number columns in the same table. It's kind of pointless.

Just to give an idea on why there's no reason to do this, consider the following hypothetical table definition.

Cars
id: autonumber
otherid: autonumber
name: varchar(100)

If you insert a record with the name value of "ford" you'll have a record that looks like:
1, 1, ford

When you insert a second record, for chevy, it will look like:
2, 2, chevy

Note how both id fields have the same value?

Now, let's say you modified your table definition to seed the "otherid" starting at value 100. Doing the same inserts would yield:

1, 101, ford
2, 102, chevy

The second field just takes up space while providing nothing in return because the column can easily be computed by adding 100 to the id key.

I'm guessing that you are missing something fundamental here. If you provide details on what you are trying to accomplish and why you think you need 2 auto number fields I'm pretty certain the community can help point you in the right direction.

0

精彩评论

暂无评论...
验证码 换一张
取 消