⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 列出数据库中所有的表名 获取access库中表的个数及表的名称 用ado怎样实现 工程--->引用--->Microsoft ActiveX Data Object 2.x(版本
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Top             =   1320
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'功能:获取access库中表的个数及表的名称
'用ado怎样实现
'工程--->引用--->Microsoft ActiveX Data Object 2.x(版本号)
'----------------------------------------------------------------------------
Dim adoCN   As New ADODB.Connection                '定义数据库的连接
Dim strCnn   As New ADODB.Recordset
Dim rstSchema As New ADODB.Recordset
Dim i As Integer
    'str1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mis\试验3\1.MDB;Persist Security Info=False"
    str1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=1.MDB;Jet OLEDB:DataBase Password=22"
    adoCN.Open str1

    Set rstSchema = adoCN.OpenSchema(adSchemaTables)

    Do Until rstSchema.EOF
         If rstSchema!TABLE_TYPE = "TABLE" Then
            out = rstSchema!TABLE_NAME
            MsgBox out
             i = i + 1
         End If
         rstSchema.MoveNext
    Loop
    MsgBox i & " 个表"
    rstSchema.Close

    adoCN.Close
    Debug.Print out
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -