将 MS Visual Foxpro .dbf 表导入 MS Access 2007

发布于 2024-08-04 00:30:02 字数 43 浏览 6 评论 0原文

有谁知道如何将 .dbf 文件导入到 MS ACcess 2007 中?

Does anyone know how to import .dbf file into MS ACcess 2007?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别低头,皇冠会掉 2024-08-11 00:30:02

您想以编程方式执行此操作吗?

MS-Access 可以选择导入表,或者您可以创建链接表。

编辑:打开 MS-Access MDB,转到表。右键单击->导入->选择适当的数据库类型(在您的情况下可以是 dbf)。

Do you want to do this programmatically?

MS-Access has option to import the tables OR you could create a Linked Table.

EDIT: Open the MS-Access MDB, goto tables. Right click -> Import -> Choose the appropriate database type (could be dbf in your case).

塔塔猫 2024-08-11 00:30:02

实际提取此信息的 VBA 方法是创建一个连接对象,连接到要从中提取的表的目录。

之后,打开一个记录集,根据该连接从表中查询您需要的内容。直接连接和扫描的一大好处是,您不会增加数据库中的表,从而使您更接近下一次修复/压缩。

然而,为了获得此连接,我需要某种 ODBC 连接器,当我切换到新的工作 PC 时,网络管理员在我背后安装了该连接器,但它在连接时突然中断。如果这是您将在无法访问此内容的其他用户电脑上使用的东西(如果这是您将在正常基础上执行的查询),那么它可能无法对其他人正常运行...

Well a VBA approach to pragmatically pull this information is to create a connection object connecting to the directory of the tables you want to pull from.

After that open a recordset to query what you need from the tables against that connection. A big benefit of directly connecting and scanning is that your not bulking up tables in your database to push you closer to your next repair/compact.

In order to get this connection however I needed some kind of ODBC connector, something the network admins came and installed behind my back when I switched to a new work PC and it suddenly broke upon connection. If this is something you would be using on other users PCs who won't have access to this (if this is a query you will be performing on a normal basis) it may not function properly for others...

闻呓 2024-08-11 00:30:02

我知道这是一个老问题,但最近我被迫尝试使用 FoxPro 表,并认为我可以在此事上添加 2 美分。

首先,您需要确定 .dbf 文件是 dbase 还是 Foxpro 表。一旦确定了要使用的表类型,就有两个选项。

选项 1:手动链接表。就像 @shahkalpesh 提到的那样,但我将更详细地介绍一下:

选项 1A (Dbase):单击“外部数据”选项卡 ->点击“新数据源”下拉菜单->选择“来自数据库”,然后选择 dbase。将弹出一个向导,允许您浏览数据库表,并且您可以选择是否导入或链接所述表。

选项1B(Foxpro):单击“外部数据”选项卡->点击“新数据源”下拉菜单->选择“来自其他来源”->然后是 ODBC 连接(见注 1)。 ->选择是否要导入或链接表格然后单击“确定”->在弹出的窗口中,转到“机器数据源”选项卡,然后双击“Visual FoxPro 表”。 ->在下一个屏幕中单击“Free Table Directory”单选按钮,然后选择“浏览”->“浏览”。浏览到您的 PC 或网络上包含 .dbf 文件的文件夹,然后单击“确定”。 ->再次单击“确定”,然后选择您要导入/链接的表。

注意 1:现在 Access 具有连接到 dbase 文件的内置功能,但对于 Foxpro 文件,您需要下载 VFPODBC 驱动程序 (google vfpodbc.msi),以便“Visual FoxPro Tables”选项出现在“机器数据源”选项卡。

选项 2 以编程方式导入:正如@David-W-Fenton 建议使用transferdatabase 命令

DoCmd.TransferDatabase acImport, "ODBC Database",_
"ODBC Database", "ODBC;DSN=pcMRPVFP;SourceDB=u:\PC MRP;SourceType=DBF;_
Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;",_ 
acTable, "(your dbf table)", "(table in your access database)"

请注意,您的连接字符串将与我的不同,即“DSN”和“SourceDB”。如果您在构建连接字符串时遇到问题,可以尝试手动链接到 .dbf 文件,在设计视图中打开它,然后在表属性表的描述字段中,您可以找到 access 用于创建链接的连接字符串得到一个想法。以下链接对于 Foxpro 表的连接字符串语法也很有帮助:

https://www.connectionstrings .com/visual-foxpro/#google_vignette

I know this is an old question but I've been forced recently to try and work with foxpro tables and thought i could add my 2-cents on the matter.

Well first you need to determine if the .dbf files are dbase or foxpro tables. Once you determine which type of table you're working with there are two options.

Option 1: manually link the tables. Like @shahkalpesh mentioned, but i'll go into a bit more detail:

Option 1A (Dbase): Click the "External Data" tab -> Click the "New Data Source" dropdown -> select "From Database" then select dbase. A wizard will pop up which allows you to browse for your dbase table and you can select whether to import or link said table.

Option 1B (Foxpro): Click the "External Data" tab -> Click the "New Data Source" dropdown -> select "from other sources"-> then ODBC connection (See note 1). -> Select whether you want to import or link the table then click "OK" -> In the window that pops up go to the "Machine Data Source" tab and double-click on "Visual FoxPro Tables". -> in the next screen click the "Free Table Directory" radio button then select browse -> browse to the folder on your PC or network that contains your .dbf files then click ok. -> click ok again and vois la, select whichever tables you want to import/link.

Note 1: Now Access has the built-in ability to connect to dbase files but for foxpro files, you'll need to download the VFPODBC driver (google vfpodbc.msi) in order for the "Visual FoxPro Tables" option to appear in the "Machine Data Source" tab.

Option 2 Programmatically Import: As @David-W-Fenton suggests use the transferdatabase command

DoCmd.TransferDatabase acImport, "ODBC Database",_
"ODBC Database", "ODBC;DSN=pcMRPVFP;SourceDB=u:\PC MRP;SourceType=DBF;_
Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;",_ 
acTable, "(your dbf table)", "(table in your access database)"

Note that your connection string will be different than mine, namely the "DSN" and "SourceDB". If you have trouble building the connection string you can try manually linking to your .dbf file, open it in design view, then in the description field of the table properties sheet you can find the connection string that access used to create the link just to get an idea. The following link is also helpful for connection string syntax with foxpro tables:

https://www.connectionstrings.com/visual-foxpro/#google_vignette

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文