1、1.VB 如何获取 ACCESS 数据库中的所有表名。2.VB 如何获得指定表的所有字段名称?Sub getTableName()Dim RS As ADODB.RecordsetDim CN As ADODB.ConnectionSet CN = New ADODB.ConnectionCN.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Access 数据库名.mdb;Persist Security Info=False“Set RS = CN.OpenSchema(adSchemaTables, Array(Empty, Empty
2、, Empty, Empty)Do Until RS.EOFIf Left(RS!table_name, 4) “MSys“ ThenList1.AddItem RS!table_nameEnd IfRS.MoveNextLoopRS.CloseSet RS = NothingCN.CloseSet CN = NothingEnd SubSub getFieldName()Dim RS As ADODB.RecordsetDim CN As ADODB.ConnectionDim FN As ADODB.FieldSet CN = New ADODB.ConnectionSet RS = Ne
3、w ADODB.RecordsetCN.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=access.mdb;Persist Security Info=False“RS.Open “表名“, CNFor Each FN In RS.FieldsList2.AddItem FN.NameNextRS.CloseSet RS = NothingCN.CloseSet CN = NothingEnd SubVB 读取 ACCESS 数据库中所有表名conn 是 ADODB.ConnectionRS 是 ADODB.RecordSet以上两个变量,只要写个数据库的人都知道set rs=conn.OpenSchema(20)do until rs.eofif ucase(rs(“TABLE_TYPE“) =“TABLE“ thenmsgbox “表:“ & rs(“TABLE_NAME“)end ifrs.movenextloop