<! -- # 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