ADOX vbs class, extract table names, column names, etc.

Source: Internet
Author: User

<! -- # Include virtual = "/include/Conn. Inc" -->
<%
'*********************************
'* Classname: adoxdbopr
'* Producer: Liu Xiaoyi
'* Role: perform database operations using ADOX
'* Version: 1.0
'**********************************
Class adoxdbopr

Dim objadox

Private sub class_initialize
Set objadox = server. Createobject ("ADOX. catalog ")
End sub

Public property let connection (objconn)
Objadox. activeconnection = objconn
End Property

Public Function arrtname
Dim arrtnames ()
Dim I: I = 1
For each objtab in objadox. Tables
If objtab. type = "table" then
Redim preserve arrtnames (I)
Arrtnames (I-1) = objtab. Name
I = I + 1
End if
Next
Arrtname = arrtnames
End Function

Public Function arrfinfo (sztname)
Dim arrf ()
Set objtadox = objadox. Tables. Item (sztname)
For I = 0 to objtadox. Columns. Count-1
Set dicinfo = server. Createobject ("scripting. Dictionary ")
Redim preserve arrf (I + 1)
Dicinfo. Add "name", objtadox. Columns. Item (I). Name
Dicinfo. Add "type", type_int2str (objtadox. Columns. Item (I). type)
Set arrf (I) = dicinfo
Set dicinfo = nothing
Next
Arrfinfo = arrf
End Function

Public sub del_table (sztname)
Objadox. Tables. Delete sztname
End sub

Public sub add_table (sztname)
Set obj_tab = server. Createobject ("ADOX. Table ")
Obj_tab.name = sztname
Set obj_tab.parentcatalog = objadox
Objadox. Tables. append obj_tab
Set obj_tab = nothing
End sub

Public sub delcolumns (arrcolumns, sztname)
Set obj_tab = objadox. Tables. Item (sztname)
If isarray (arrcolumns) then
For I = 0 to ubound (arrcolumns)
Obj_tab.columns.delete arrcolumns (I)
Next
Else
Obj_tab.columns.delete arrcolumns
End if
End sub

Public sub add_columns (arrcolumns, sztname)
Set objtab = objadox. Tables. Item (sztname)
For I = 0 to ubound (arrcolumns)
Objtab. Columns. append arrcolumns (I, 0), arrcolumns (I, 1), arrcolumns (I, 2)
Next
End sub

Function type_int2str (int_value)
Select case int_value
Case 3:
Type_int2str = "Number"
Case 202:
Type_int2str = "text"
Case else:
Type_int2str = int_value
End select
End Function

Private sub class_terminate
Set objadox = nothing
End sub

End Class

%>

I have read the blog and I have referenced this class in many other places, but I have never published it myself.
Some people do not know how to use it in the blue sky ideal. I found it in Baidu. Here I post it for you to have fun... Haha

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.