vbs adox提取数据库表名和列名的类
(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
<!--#include virtual="/include/conn.inc"-->
<%
'*********************************
'* classname: ADOXDBOPR
'* 制作人: 刘晓逸
'* 作用: 用adox进行数据库的操作
'* 版本: 1.0
'*www.jb51.net
'**********************************
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="数字"
case 202:
type_int2str="文本"
case else:
type_int2str=int_value
end select
end function
Private Sub Class_Terminate
Set objADOX=nothing
End Sub
End class
%>
<%
'*********************************
'* classname: ADOXDBOPR
'* 制作人: 刘晓逸
'* 作用: 用adox进行数据库的操作
'* 版本: 1.0
'*www.jb51.net
'**********************************
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="数字"
case 202:
type_int2str="文本"
case else:
type_int2str=int_value
end select
end function
Private Sub Class_Terminate
Set objADOX=nothing
End Sub
End class
%>
下一篇:查看或修改Windows系列系统的序列号的vbs