VB6应用程序可能需要生成自己的ACCESS AUTONUMBER VALUES ??? [英] VB6 app may need to generate its own ACCESS AUTONUMBER VALUES???

查看:67
本文介绍了VB6应用程序可能需要生成自己的ACCESS AUTONUMBER VALUES ???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究的项目将使用VB6作为前端。返回

end将是预先存在的MS Access 2002数据库表,其中
已经有记录*但是没有任何自动编号*字段

in。


纠正我,如果我错了,但我假设这意味着我现在不能改变这些现有的Access表并将其主键更改为

" AutoNumber"类型。


如果我是对的,我需要一些关于最有效和可靠的创建VB6功能的方法的建议。返回

a数字代表

特定表格中的下一个可用主要数字。


换句话说,我*认为* (再次,纠正我,如果我错了)我需要

在VB6中创建一个自动编号生成函数。


其中一个问题我''我正在努力解决的问题是,我的VB应用程序可能会被一次超过10人使用。那么,除了你对我上面描述的内容有什么建议之外,

它会帮助我知道我会怎么做确保我的VB应用程序没有两个同时用户将生成相同的

''autonumber''值;因为我显然需要

问题中的主要字段,每个记录总是有一个唯一的值。


顺便说一下,它的价值是什么我可能会在

VB应用程序中使用ADO。


提前感谢您提供的任何帮助。

A project I''m working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any AutoNumber* fields
in them.

Correct me if I''m wrong, but I''m assuming this means that I cannot now
alter these existing Access tables and change their primary key to an
"AutoNumber" type.

If I''m right about this, I need some suggestions as to the most
efficient and reliable way of creating a VB6 function that will return
a number that represents the next available primary number in a
particular table.

In other words, I *think* (again, correct me if I''m wrong) I need to
create an AutoNumber generating function in VB6.

One of the issues I''m grappling with is that my VB app may be used by
more than 10 people at a time. So, in addition to whatever
suggestions you have as to how I go about what I''ve described above,
it would help me to know how I would go about making sure that no two
simultaneous users of my VB app will ever generate identical
''autonumber'' values; because I obviously need the primary field in
question to always have a unique value for each record.

By the way, for what it''s worth I''m probably going to use ADO in the
VB app.

Thanks in advance for any help you can provice.

推荐答案



Alan Mailer写道:

Alan Mailer wrote:

我正在工作的项目on将使用VB6作为前端。返回

end将是预先存在的MS Access 2002数据库表,其中
已经有记录*但是没有任何自动编号*字段

in。


纠正我,如果我错了,但我假设这意味着我现在不能改变这些现有的Access表并将其主键更改为

" AutoNumber"类型。


如果我是对的,我需要一些关于最有效和可靠的创建VB6功能的方法的建议。返回

a数字代表

特定表格中的下一个可用主要数字。


换句话说,我*认为* (再次,纠正我,如果我错了)我需要

在VB6中创建一个自动编号生成函数。


其中一个问题我''我正在努力解决的问题是,我的VB应用程序可能会被一次超过10人使用。那么,除了你对我上面描述的内容有什么建议之外,

它会帮助我知道我会怎么做确保我的VB应用程序没有两个同时用户将生成相同的

''autonumber''值;因为我显然需要

问题中的主要字段,每个记录总是有一个唯一的值。


顺便说一下,它的价值是什么我可能会在

VB应用程序中使用ADO。


预先感谢您提供任何帮助。
A project I''m working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any AutoNumber* fields
in them.

Correct me if I''m wrong, but I''m assuming this means that I cannot now
alter these existing Access tables and change their primary key to an
"AutoNumber" type.

If I''m right about this, I need some suggestions as to the most
efficient and reliable way of creating a VB6 function that will return
a number that represents the next available primary number in a
particular table.

In other words, I *think* (again, correct me if I''m wrong) I need to
create an AutoNumber generating function in VB6.

One of the issues I''m grappling with is that my VB app may be used by
more than 10 people at a time. So, in addition to whatever
suggestions you have as to how I go about what I''ve described above,
it would help me to know how I would go about making sure that no two
simultaneous users of my VB app will ever generate identical
''autonumber'' values; because I obviously need the primary field in
question to always have a unique value for each record.

By the way, for what it''s worth I''m probably going to use ADO in the
VB app.

Thanks in advance for any help you can provice.



您始终可以向表中添加新的自动编号字段。您甚至可以添加一个新的自动编号字段,删除原始的

非自动编号关键字段,并将新字段重命名为旧密钥

字段的名称。在这种情况下,您必须确保适当地更新

任何外键,即,您需要确保相关表中的所有记录仍然匹配

现在自动编号表中的相应

记录。人们不禁要知道在你的应用程序之前在该数据库中是如何生成主键的。


我不推荐ADO,除非你设想升级你的后端

数据库在不久的将来或绝对需要DAO

不提供的功能。使用Jet数据库时,DAO的工作效率比

ADO更高效。


希望这会有所帮助,

布鲁斯

You can always add a new autonumber field to the table. You can even
go so far as to add a new autonumber field, delete the original
non-autonumber key field, and rename your new field to the old key
field''s name. In this case you will have to make sure that you update
any foreign keys appropriately however, i.e., you will need to make
sure that all records in related tables still match the appropriate
records in your now autonumbered table. One has to wonder how primary
keys were generated in that database prior to your application however.

I wouldn''t recommend ADO unless you envision upsizing your back end
database in the near future or absolutely need functionality that DAO
does not provide. DAO works more efficiently with a Jet database than
ADO does.

Hope this helps,
Bruce


不,您仍然可以添加自动编号。访问将自动为数据库中的所有记录创建
genereate值。您可以通过

发出ALTER TABLE DDL语句,或者只是打开数据库和

自己进行更改。


Chris Nebinger

Alan Mailer写道:
Nope, you can still add AutoNumbers. Access will automatically
genereate values for all records in the database. You can do this by
issuing an ALTER TABLE DDL statement, or just opening the database and
making the change yourself.

Chris Nebinger
Alan Mailer wrote:

我正在研究的项目将使用VB6作为前端。返回

end将是预先存在的MS Access 2002数据库表,其中
已经有记录*但是没有任何自动编号*字段

in。


纠正我,如果我错了,但我假设这意味着我现在不能改变这些现有的Access表并将其主键更改为

" AutoNumber"类型。


如果我是对的,我需要一些关于最有效和可靠的创建VB6功能的方法的建议。返回

a数字代表

特定表格中的下一个可用主要数字。


换句话说,我*认为* (再次,纠正我,如果我错了)我需要

在VB6中创建一个自动编号生成函数。


其中一个问题我''我正在努力解决的问题是,我的VB应用程序可能会被一次超过10人使用。那么,除了你对我上面描述的内容有什么建议之外,

它会帮助我知道我会怎么做确保我的VB应用程序没有两个同时用户将生成相同的

''autonumber''值;因为我显然需要

问题中的主要字段,每个记录总是有一个唯一的值。


顺便说一下,它的价值是什么我可能会在

VB应用程序中使用ADO。


预先感谢您提供任何帮助。
A project I''m working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any AutoNumber* fields
in them.

Correct me if I''m wrong, but I''m assuming this means that I cannot now
alter these existing Access tables and change their primary key to an
"AutoNumber" type.

If I''m right about this, I need some suggestions as to the most
efficient and reliable way of creating a VB6 function that will return
a number that represents the next available primary number in a
particular table.

In other words, I *think* (again, correct me if I''m wrong) I need to
create an AutoNumber generating function in VB6.

One of the issues I''m grappling with is that my VB app may be used by
more than 10 people at a time. So, in addition to whatever
suggestions you have as to how I go about what I''ve described above,
it would help me to know how I would go about making sure that no two
simultaneous users of my VB app will ever generate identical
''autonumber'' values; because I obviously need the primary field in
question to always have a unique value for each record.

By the way, for what it''s worth I''m probably going to use ADO in the
VB app.

Thanks in advance for any help you can provice.


感谢所有到目前为止试图解决我的问题的人。

这个群体仍然是一个精彩的资源!


阅读完回复后,我想我需要更具体的

我需要什么,不需要什么:


我不只是想在现有的表中添加一个新列,即
恰好使用自动编号格式。我相信我需要开始

以编程方式提供*现有的*主要(''数字''数据类型)

字段,其中包含字段本身不能的唯一数字(因为$(原始设计表)的方式)自动生成。


让我这样说吧:想象一下现有的记录在

tblContact。该表的主要ID字段是ContactID。

不幸的是,之前的程序员没有将ContactID建立为自动编号字段。

。尽管如此,tblContact中已存在数百条记录

;所有这些都有自己独特的

ContactID,所有这些都被用作其他

表中的外键。换句话说,这些现有的联系人记录现在不能让他们的联系人ID更改了。


我的任务是每当用户使用我的VB6应用程序创建一个新的时候

联系人记录,我需要在tblContact上附加一条记录,这将是
有一个UNIQUE Con​​tactID。我的应用程序需要承担这个责任,

因为Access表不能。


理想情况下,我希望我可以改变现有的ContactID字段

属性为AutoNumber并且知道新记录将永远

之后从

tblContacts中最大的现有ContactID开始递增...但是我'在印象中,Access不允许我这样做。
这样做。


这就是为什么我想我现在必须写一个例程,以便VB6可以

(例如)在VB6之前查看tblContacts中的MAX ContactID

将新记录附加到该表...以便VB6可以提供

新记录的ContactID值相当于

''MAX''加1.


除非我错过了一些东西(天知道,我可能会),一个新的

自动编号栏将*不*给我我需要的东西......一件事

因为那个对于已经建立了''ContactID''值的记录,ew列将自动包含其自己的''default''

值。

且不应更改。


我希望我在这里不要过分解释,或者听起来像是在抱怨我已经收到的答案。我只想尝试一下

更多关于我需要的内容。


再次,我需要编写VB6例程''auto增加''例程

以确保应用程序的两个同时用户不会产生相同的ContactIDs。


再次感谢您的所有投入。我期待你的进一步回复。


2006年9月11日11:36:46 -0700,ch ******* *****@gmail.com"

< ch ************ @ gmail.comwrote:
Thank you to all who have attempted to lend a hand to my issue so far.
This group continues to be a wonderful resource!

After reading the responses, I''m thinking I need to be a more specific
about what I need and don''t need:

I am not just looking to add a new column to an existing table that
happens to use AutoNumber format. I believe I need to start
programmatically providing an *existing* primary (''Number'' data type)
field with unique numbers that the field itself cannot (because of the
way the table was originally designed) automatically generate.

Let me put it this way: Imagine that there are existing records in
tblContact. That table''s primary ID field is ContactID.
Unfortunately, the previous programmer did not establish ContactID as
an AutoNumber field. Nevertheless, there are now hundreds of records
which already exist in tblContact; all with their own unique
ContactIDs, all of which have been used as foreign keys in other
tables. In other words, these existing Contact records cannot now
have their ContactIDs changed.

My mandate is that whenever the user uses my VB6 app to create a new
Contact record, I need to append a record to tblContact which will
have a UNIQUE ContactID. My app needs to take on that responsibility,
because the Access table cannot.

Ideally, I wish I could just change the existing ContactID''s field
property to AutoNumber and know that new records would forever
afterwards increment starting from the largest existing ContactID in
tblContacts... but I''m under the impression Access won''t allow me to
do this.

This is why I''m thinking I have to now write a routine so that VB6 can
(for example) look at the MAX ContactID in tblContacts before VB6
appends a new record to that table... so that VB6 can then provide
that new record with a ContactID value that is the equivalent of that
''MAX'' plus 1.

Unless I''m missing something (and God knows, I might be), a new
AutoNumbering column will *not* give me what I need... for one thing
because that new column will automatically contain its own ''default''
values for records whose ''ContactID'' values are already established
and should not be changed.

I hope I''m not over-explaining here, or sound like I''m complaining
about the answers I''ve received so far. I''m just trying to be a bit
more specfic about what I need.

Again, I would need to write the VB6 routine ''auto increment'' routine
in a way that insures that no two simultaneous users of the app will
ever generate identical ContactIDs.

Thanks again for all your input. I look forward to your further
responses.

On 11 Sep 2006 11:36:46 -0700, "ch************@gmail.com"
<ch************@gmail.comwrote:

>不,您仍然可以添加自动编号。 Access将自动生成数据库中所有记录的值。您可以通过发出ALTER TABLE DDL语句,或者只是打开数据库并自行进行更改来完成此任务。

Chris Nebinger

Alan Mailer写道:
>Nope, you can still add AutoNumbers. Access will automatically
genereate values for all records in the database. You can do this by
issuing an ALTER TABLE DDL statement, or just opening the database and
making the change yourself.

Chris Nebinger
Alan Mailer wrote:

>我正在研究的项目将使用VB6作为前端。后面的
结束将是预先存在的MS Access 2002数据库表,其中已经有记录*但其中没有任何自动编号*字段
<如果我错了,请纠正我,但我假设这意味着我现在无法改变这些现有的Access表并将其主键更改为
AutoNumber。类型。

如果我是对的,我需要一些关于创建VB6函数的最有效和最可靠的方法的建议,这将返回
一个数字表示
特定表格中的下一个可用主要数字。

换句话说,我*想*(再次,如果我错了,请纠正我)我需要
在VB6中创建一个自动编号生成函数。

我正在努力解决的一个问题是我的VB应用程序一次可能被超过10个人使用。所以,除了你对我上面描述的内容有什么建议之外,
这将有助于我知道如何确保没有两个
我的VB应用程序的同时用户将生成相同的
''autonumber''值;因为我显然需要问题中的主要字段,每个记录总是有一个独特的值。

顺便说一下,为了它的价值,我可能会使用它在VB应用程序中的ADO。

提前感谢您提供任何帮助。
>A project I''m working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any AutoNumber* fields
in them.

Correct me if I''m wrong, but I''m assuming this means that I cannot now
alter these existing Access tables and change their primary key to an
"AutoNumber" type.

If I''m right about this, I need some suggestions as to the most
efficient and reliable way of creating a VB6 function that will return
a number that represents the next available primary number in a
particular table.

In other words, I *think* (again, correct me if I''m wrong) I need to
create an AutoNumber generating function in VB6.

One of the issues I''m grappling with is that my VB app may be used by
more than 10 people at a time. So, in addition to whatever
suggestions you have as to how I go about what I''ve described above,
it would help me to know how I would go about making sure that no two
simultaneous users of my VB app will ever generate identical
''autonumber'' values; because I obviously need the primary field in
question to always have a unique value for each record.

By the way, for what it''s worth I''m probably going to use ADO in the
VB app.

Thanks in advance for any help you can provice.


这篇关于VB6应用程序可能需要生成自己的ACCESS AUTONUMBER VALUES ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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