Chức năng: Trả lại một mảng chứa tên của tất cả các bảng trong database
Ngôn ngữ: asp - Nhóm: database
CÚ PHÁP
array = Tables(connstring)
Trả lại một mảng chứa tên của tất cả các bảng trong DB.
Cần đối số connstring là một OLE DB xác định đang kết nối.
VÍ DỤ
<%
dim i, ar, cn
cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath ("/database/mydata.mdb") & ";"
ar = Tables(cn)
for i = 0 to ubound(ar) - 1
'--- write each table name to the browser
response.write ar(i) & "<BR>"
next
%>
ASP Code
<%
Private Function Tables(byval connstring)
Dim adox, i, strTables
Set adox = Server.CreateObject("ADOX.Catalog")
adox.ActiveConnection = connstring
for i = 0 to adox.tables.count - 1
if UCase( adox.tables(i).type ) = "TABLE" then
strTables = strTables & adox.tables(i).name & vbCrLf
end if
next
Set adox = nothing
Tables = split( strTables, vbCrLf )
End Function '--- Tables
%>