当前位置: 网学 > 编程文档 > VB > 正文

VB中打开常用数据库

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式

''数据库类型.
Public Enum SmDbType
            Access = 1    ''Access
            Excel = 2     ''Excel
            Text = 3      ''文本
            FoxPro = 4    ''FoxPro
            dBase = 5     ''dBase
End Enum
''
''创建一个连接(连接到其它数据库类型)
''函数名:CreateOtherConn
''参数:  DbConnection ADODB连接,FilePath 数据库路径,UserName 登录用户名,PassWord 登录密码,DbType SmDbType枚举数据库类型
''返回值:TRUE 连接成功.FALSE 连接失败.
''例:
''CreateOtherConn Cnn, "E:\CjhLx\dbf", , , FoxPro
''StrSql = "select * from [employee.dbf]"
''Set Rs = RsOpen(Cnn, StrSql)
''Set DataGrid1.DataSource = Rs

Public Function CreateOtherConn(ByRef DbConnection As ADODB.Connection, _
                               FilePath As String, _
                               Optional UserName As String = "admin", _
                               Optional PassWord As String = "", _
                               Optional DbType As SmDbType = Access) As Boolean
        Dim ConnStr As String
        Dim DriveName(5) As String
        Dim tDbType(5) As String
        Dim UserPwd(5) As String
        
        ''驱动程序
        DriveName(1) = "{Microsoft Access Driver (*.mdb)}"
        DriveName(2) = "{Microsoft Excel Driver (*.xls)}"
        DriveName(3) = "{Microsoft Text Driver (*.txt; *.csv)}"
        DriveName(4) = "{Microsoft Visual FoxPro Driver};SourceType=DBF"
        DriveName(5) = "{Microsoft dBase Driver (*.dbf)}"
  

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号