获取数据库所有表的表名
程序代码:
Function ReDBTableCount(rsSchema) Dim DbTCount DbTCount=0 Do Until rsSchema.EOF DbTCount=DbTCount+1 rsSchema.MoveNext Loop rsSchema.MoveFirst ReDBTableCount=DbTCount End Function '返回数据库所有表名方法(适用于Access数据库) '参数ADODB.Connection ,Dim定义的数组 Function ReDBAllTableName(con,TbNAry()) Dim rsSchema Dim TbAryL TbAryL=0 Set rsSchema=con.OpenSchema(20) ReDim TbNAry(ReDBTableCount(rsSchema)) Do Until rsSchema.EOF IF TbAryL<UBound(TbNAry) Then IF InStr(rsSchema("TABLE_NAME"),"MSys")=0 And InStr(rsSchema("TABLE_NAME"),"查询")=0 Then TbNAry(TbAryL)=rsSchema("TABLE_NAME") Else TbNAry(TbAryL)="" End IF End IF TbAryL=TbAryL+1 rsSchema.MoveNext Loop rsSchema.Close Set rsSchema=Nothing End Function '用法 '假设conn为ADODB.Connection Dim i,TBNAry() ReDBAllTableName conn,TBNAry For i=0 To UBound(TBNAry)-1 IF TBNAry(i)<>"" Then Response.Write "表名:"&TBNAry(i)&"<br>" End IF Next