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