vbs adox提取数据库表名和列名的类
程序员文章站
2022-04-10 19:26:10
<% '************************...
<!--#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
%>
下一篇: 草船借箭时,曹操有没有想过放火箭?