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="数字" case 202: type_int2str="文本" case else: type_int2str=int_value end select end function
Private Sub Class_Terminate Set objADOX=nothing End Sub