如何以编程方式创建数据库和表并将其链接到另一个 [英] How to programmatically create a DB and a table and link it to another

查看:78
本文介绍了如何以编程方式创建数据库和表并将其链接到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


好​​的,我正在使用VB6,但我认为这个(如果有的话)的答案更有可能在Access论坛中找到。


我有一种情况,我有数千万条记录,分布在一堆独立的数据库中。我没有选择这个,因为数据对于单个MDB来说太大了。到目前为止,我还没准备好去SQL Server。可能在不太遥远的未来,但我们会看到。与此同时,我有一堆大型数据库(比如每个半千兆字节)都有相同的单个表(相同的结构)。然后我有一个前端数据库,它有所有链接,并且还有一个与每个数据库相关的查询定义(用一个或两个查找表连接它们)。


我使用VB6程序读取一些定期生成的日志文件,并以精简的形式生成信息。然后,我使用VBA例程将信息导入最新表,更新一些统计信息等等。 (统计数据可以从数据中动态生成,但我通常不想等待一两天。)


问题是,随着更多数据的记录,我必须手动创建下一个数据库,使用空表,然后将其链接到前端,然后为它创建查询,依此类推。我正在寻求自动执行此操作,并且为了好的措施,我计划将这两个步骤组合成一个VB6程序,该程序读取日志并将信息直接加载到数据库中,而不是生成要导入的文本文件。 br />

所以,任何人都可以帮助我,从VB6,我可以...

Hi all.

Ok, I''m using VB6 but I think the answer to this (if there is one) is more likely to be found in the Access forum.

I have a situation where I''ve got tens of millions of records, spread over a bunch of separate databases. I don''t have a choice about this, as the data is simply too large for a single MDB. As yet, I''m not prepared to go to SQL Server. Possibly in the not-too-distant future, but we''ll see. In the meantime, I have this bunch of large-ish databases (say, half a gigabyte each) all with the same single table (identical structure). I then have a front-end database which has all of them linked, and also has a query definition related to each one (to join them up with one or two lookup tables).

I use a VB6 program to read some regularly-generated log files and produce information in a condensed form. I then use a VBA routine to import the info to the latest table, update some stats and so forth. (The stats can be generated on the fly from the data, but I don''t usually want to wait a day or two for them).

The problem is that as more data is recorded, I have to manually create the next database, with its empty table, then link it to the front-end, then create the query for it, and so on. I''m looking to automate this, and just for good measure I plan to combine the two steps into a single VB6 program which reads the logs and loads the info directly into the database, instead of producing a text file to be imported.

So, can anyone help me on how, from VB6, I can...

  1. 创建一个包含一个MDB的MDB空表
  2. 将表链接到我的前端数据库,
  3. (可能是简单的)基于链接表创建新的查询定义?



顺便说一句,我很好用这背后的所有逻辑 - 我可以毫无顾虑地构建应用程序。我只是需要帮助来了解如何实现这些特定任务。尝试过搜索,我发现的最好的是如何在现有数据库中创建表格的提示。


我想我可以通过复制一个相对简单地完成任务#1 ;股票" MDB和更改名称,但更喜欢从头开始创建它。任务#3可能不是太难 - 我希望我可以通过一些工作来解决这个问题。但是#2让我难过。


I''m fine with all the logic behind this, by the way - I can build the application no worries. I just need help on how to achieve these specific tasks. Have tried searching, and the best I found was a hint on how to create a table in an existing database.

I suppose I can achieve task #1 relatively simply by just copying a "stock" MDB and changing the name, but would prefer to create it from scratch. Task #3 is probably not too tough - I expect I can figure that one out with a bit of work. But #2 has me stumped.

推荐答案


大家好。


好吧,我正在使用VB6,但我认为这个(如果有的话)的答案更有可能在Access论坛中找到。


我有一种情况我有数以千万计的记录,分布在一堆独立的数据库中。我没有选择这个,因为数据对于单个MDB来说太大了。到目前为止,我还没准备好去SQL Server。可能在不太遥远的未来,但我们会看到。与此同时,我有一堆大型数据库(比如每个半千兆字节)都有相同的单个表(相同的结构)。然后我有一个前端数据库,它有所有链接,并且还有一个与每个数据库相关的查询定义(用一个或两个查找表连接它们)。


我使用VB6程序读取一些定期生成的日志文件,并以精简的形式生成信息。然后,我使用VBA例程将信息导入最新表,更新一些统计信息等等。 (统计数据可以从数据中动态生成,但我通常不想等待一两天。)


问题是,随着更多数据的记录,我必须手动创建下一个数据库,使用空表,然后将其链接到前端,然后为它创建查询,依此类推。我正在寻求自动执行此操作,并且为了好的措施,我计划将这两个步骤组合成一个VB6程序,该程序读取日志并将信息直接加载到数据库中,而不是生成要导入的文本文件。 br />

所以,任何人都可以帮助我,从VB6,我可以...
Hi all.

Ok, I''m using VB6 but I think the answer to this (if there is one) is more likely to be found in the Access forum.

I have a situation where I''ve got tens of millions of records, spread over a bunch of separate databases. I don''t have a choice about this, as the data is simply too large for a single MDB. As yet, I''m not prepared to go to SQL Server. Possibly in the not-too-distant future, but we''ll see. In the meantime, I have this bunch of large-ish databases (say, half a gigabyte each) all with the same single table (identical structure). I then have a front-end database which has all of them linked, and also has a query definition related to each one (to join them up with one or two lookup tables).

I use a VB6 program to read some regularly-generated log files and produce information in a condensed form. I then use a VBA routine to import the info to the latest table, update some stats and so forth. (The stats can be generated on the fly from the data, but I don''t usually want to wait a day or two for them).

The problem is that as more data is recorded, I have to manually create the next database, with its empty table, then link it to the front-end, then create the query for it, and so on. I''m looking to automate this, and just for good measure I plan to combine the two steps into a single VB6 program which reads the logs and loads the info directly into the database, instead of producing a text file to be imported.

So, can anyone help me on how, from VB6, I can...
  1. 创建一个包含一个MDB的MDB空表
  2. 将表链接到我的前端数据库,
  3. (可能是简单的)基于链接表创建新的查询定义?



顺便说一句,我很好用这背后的所有逻辑 - 我可以毫无顾虑地构建应用程序。我只是需要帮助来了解如何实现这些特定任务。尝试过搜索,我发现的最好的是如何在现有数据库中创建表格的提示。


我想我可以通过复制一个相对简单地完成任务#1 ;股票" MDB和更改名称,但更喜欢从头开始创建它。任务#3可能不是太难 - 我希望我可以通过一些工作来解决这个问题。但#2让我难过。


I''m fine with all the logic behind this, by the way - I can build the application no worries. I just need help on how to achieve these specific tasks. Have tried searching, and the best I found was a hint on how to create a table in an existing database.

I suppose I can achieve task #1 relatively simply by just copying a "stock" MDB and changing the name, but would prefer to create it from scratch. Task #3 is probably not too tough - I expect I can figure that one out with a bit of work. But #2 has me stumped.



我曾经一直这样做,但那是在Access 2中,我不再拥有我的解决方案的副本,也不记得我是怎么做到的。但是,我进行了搜索,本文解释了如何执行第2步,并提供了所需的代码。
http://www.alvechurchdata.co.uk/acclink.htm



...本文解释了如何执行第2步,并提供了您需要的代码。
http://www.alvechurchdata.co.uk/acclink.htm



谢谢,我会检查一下。


我想知道的一件事是我是否需要添加对Access对象库的引用,然后以我们使用Word或Excel的方式使用Access。我猜测ADO不想知道Access的机制,因为它是一个更通用的任何数据库。连接。


无论如何,我在漫无边际。我会去看看这个链接。

Thanks, I''ll check it out.

One thing I''ve been wondering is whether I might need to add a reference to the Access object library, then play with Access the way we use Word or Excel. I''m guessing ADO doesn''t want to know about the mechanics of Access, since it''s a more generic "any database" connection.

Anyway, I''m rambling. I''ll go have a look at the link.



谢谢,我会检查一下。


我想知道的一件事是我是否需要添加对Access对象库的引用,然后以我们使用Word或Excel的方式使用Access。我猜测ADO不想知道Access的机制,因为它是一个更通用的任何数据库。连接。


无论如何,我在漫无边际。我会去看看这个链接。
Thanks, I''ll check it out.

One thing I''ve been wondering is whether I might need to add a reference to the Access object library, then play with Access the way we use Word or Excel. I''m guessing ADO doesn''t want to know about the mechanics of Access, since it''s a more generic "any database" connection.

Anyway, I''m rambling. I''ll go have a look at the link.



嗨!


这是创建新mdb的非常基本的代码,添加一个简单的表并将其链接到当前数据库。

Hi!

Here is very basic code creating new mdb, adding to it a simple table and linking it to the current db.

展开 | 选择 | Wrap | 行号


这篇关于如何以编程方式创建数据库和表并将其链接到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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