Vbs adox class used to extract database table names and column names

Source: Internet
Author: User

<! -- # Include virtual = "/include/conn. inc" -->
<%
'*********************************
'* Classname: ADOXDBOPR
'* Producer: Liu Xiaoyi
'* Role: perform database operations using adox
'* Version: 1.0
'* Www.jb51.net script home
'**********************************
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
%>

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.