'功能:获取access库中表的个数及表的名称 '用ado怎样实现 '工程--->引用--->microsoft activex data object 2.x(版本号) '---------------------------------------------------------------------------- private sub form_load() 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=c:/northwind.mdb;persist security info=false" adocn.open str1
set rstschema = adocn.openschema(adschematables)
do until rstschema.eof if rstschema!table_type = "table" then out = out & "table name: " & _ rstschema!table_name & vbcr & _ "table type: " & rstschema!table_type & vbcr i = i + 1 end if rstschema.movenext loop msgbox i rstschema.close
查询: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=5 order by msysobjects.name;
窗体: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=-32768 order by msysobjects.name;
表: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (left$([name],4) <> "msys") and (msysobjects.type)=1 order by msysobjects.name;
报表: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32764 order by msysobjects.name;
模块: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32761 order by msysobjects.name;
宏: select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32766 order by msysobjects.name;