在不更改 Access 数据库的情况下将数据从 MS Access 数据库导入到另一个数据库的最佳方法是什么?
我在 Access 数据库 A 上有一个表(存储了 60.000 多条记录),我必须将其导入到另一个 Access 数据库 B 上的表中。
一开始,Access 数据库 B 上的表存储 Access 数据库 A 上表中的 3000 条记录
。 A 由另一个程序处理,如果我不必对其进行更改,那就最好了,我只需打开它并获取数据即可。我需要从access数据库A的表中导入更新记录和新记录来访问数据库B。
数据库A每天都会有100多条新记录和一些更新记录,我需要在最后将它们导入到数据库B中天。我需要自动执行。
新记录很容易找到,但是更新记录怎么样?通过更新记录,我需要在数据库 B 中添加新行,而不是更改数据库 B 中的任何行。
是否有更好的方法来执行此操作,也许使用 ODBC 连接或其他方式?
请帮我 ! 谢谢并致以诚挚的问候。
I have a table on access database A (store more 60.000 records), which I must import into a table on another Access database B.
In the beginning, table on Access database B stores 3000 records from table on Access database A.
The access database A is handled by another program, and it would be best if I did not have to makes changes to it, I just can open it and get data. I need import updated records and new records from table on the access database A to access database B.
Every day database A have more 100 new records and some update records, I need to import them into database B in the end of the day. I need do automatically.
The new records is easy to find but how about update records ? With update record I need to add as a new row in database B, not change any rows in database B.
Is there a better way to do this, perhaps using an ODBC connection or something else?
Please help me !
Thanks and best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有看一下这个微软网页
基本步骤是
Have a look at this microsoft web page
The basic steps are
您的数据库 B 现在“链接”到数据库 A 中的数据。现在您可以使用“联合”查询或任何您喜欢的查询将其与数据库 B 表中存储的数据组合起来。最重要的是,这不需要对数据库 A 进行任何更改。
Your database B is now "linked" to the data in database A. Now you can use a "union" query or whatever you like to combine it with data stored in your database B table. Best of all, this doesn't require any changes to database A.
要更新现有记录,您需要比较两条记录,并在目标数据库中的两条记录不相同时进行更新。
根据涉及的字段数量,这可能会很复杂。
以下是我过去用于此目的的代码:
您可以向此函数传递两个表名称或两个查询名称。这提供了很大的灵活性。它假定传递的两个对象中的字段名称相同,如果它们不是相同的名称,您可以创建一个查询来为字段添加别名,以与其他表中的字段相匹配。
这是我使用过无数次的代码的变体。基本原理是,它执行一系列 UPDATE 查询,逐列遍历表,并根据哪些行具有不同的值进行更新。
To update existing records, you need to compare the two records and update when they are not the same in the target database.
Depending on the number of fields involved, this can be complicated.
Here's code I've used for that purpose in the past:
You can pass this function two table names, or two query names. This allows lots of flexibility. It assumes the field names are the same in both the objects it is passed, and if they aren't the same name, you can create a query to alias the fields to match those in the other table.
This is a variant of code I've used a bazillion times. The basic principle is that it executes a series of UPDATE queries that go column-by-column through your table and update based on which rows have differing values.