分享

一个ACCESS数据库,我如何用VB知道他有多少个表,并且这些表的表名是什么?

 网络摘记 2014-10-26
Public Function GetTables(con As ADODB.Connection, strTable() As String) As Boolean
'函数:GetTables
'功能:列出所有存在的表
'参数:strTable 要记录的表名
    Dim cat As New ADOX.Catalog '数据库接入点
    Dim tbl As New ADOX.Table '数据库的表
    Dim i As Integer
    On Error Resume Next

    cat.ActiveConnection = con
    
    If err.Number <> 0 Then GoTo err1
    
    ReDim strTable(0) As String
    
    For Each tbl In cat.Tables
        If tbl.Type = "TABLE" Then
                i = i + 1
                ReDim Preserve strTable(i) As String
                strTable(i) = tbl.name
        End If
    Next
    If err.Number <> 0 Then GoTo err1
    
    EnumTable = True
    Exit Function
err1:
    err.Raise err.Number, "MyProj.MyObject", err.Description
End Function
Public Functio

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多