设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1464|回复: 3
打印 上一主题 下一主题

[与其它组件] 请问如何用代码打开dbf数据库?

[复制链接]
跳转到指定楼层
1#
发表于 2003-6-6 00:00:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
各位大虾好。我用access的导入外部数据库功能(选择dbase 5格式)可以导入dbf数据库,但我不知道用代码该如何实现。我打开dbf数据库的目的是要对其进行查询,然后将其查询结果报存在access数据库的表中。但我不想直接把dbf数据库导入access中。请问各位大虾有什么比较简洁的办法吗?谢谢。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2003-7-12 19:15:00 | 只看该作者
我也很想知道.....
谢谢......
3#
发表于 2003-7-17 20:11:00 | 只看该作者
''' 假如我们有一个CUSTOMER.dbf 在C:\ 后
''' NOTE: This subroutine requires that you reference the
'''       latest version of the following library:
'''
'''         Microsoft ActiveX Data Objects Library

    Dim conn As ADODB.Connection
    Dim rst As ADODB.Recordset
    '
    Dim i As Integer

    ' Create the Connection object.
    Set conn = New ADODB.Connection

    PathToDatabase = "c:\"
    With conn
        'Assign the connection string to the connection object.
        .ConnectionString = "DRIVER={Microsoft dBase Driver (*.dbf)};" & _
            "DBQ=" & PathToDatabase & ";" & _
            "DefaultDir=" & PathToDatabase & "\"
        ' Open the connection.
        .Open strConn
    End With

    ' Create a new Recordset Object.
    Set rst = New ADODB.Recordset
   
    With rst
        ' Connect this recordset to the previously opened connection.
        .ActiveConnection = conn
        ' Retrieve all records from the Customer table.
        .Open "SELECT * FROM Customer"
        
    End With

    ' 由此得出DBF 数据集。
    Set rst = Nothing
    ' Close the Connection.
    conn.Close

改自微软实例 HAMLETL

[此贴子已经被作者于2003-7-17 12:12:02编辑过]

4#
发表于 2009-6-22 16:05:29 | 只看该作者
看不懂
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-30 07:29 , Processed in 0.141768 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表