asp adox資料庫操作類

2021-04-09 05:44:41 字數 2573 閱讀 5229

adox類

<%

'*********************************

'* classname: dbopr

'* 製作人: 劉曉逸

'* 作用: 用adox進行資料庫的操作

'* 版本: 1.0

'**********************************

class dbopr

dim obj_adox

private sub class_initialize

set obj_adox=server.createobject("adox.catalog")

' obj_adox.activeconnection=connstr

end sub

public property let connection(obj_conn)

obj_adox.activeconnection=obj_conn

end property

public function arr_tname

dim tnames()

dim i : i=1

for each objtab in obj_adox.tables

if objtab.type="table" then

redim preserve tnames(i)

tnames(i-1)=objtab.name

i=i+1

end if

next

arr_tname=tnames

end function

public function arr_finfo(str_tname)

dim arr_f()

set obj_tadox=obj_adox.tables.item(str_tname)

for i=0 to obj_tadox.columns.count-1

set dic_info=server.createobject("scripting.dictionary")

redim preserve arr_f(i+1)

dic_info.add "name",obj_tadox.columns.item(i).name

dic_info.add "type",type_int2str(obj_tadox.columns.item(i).type)

set arr_f(i)=dic_info

set dic_info=nothing

next

arr_finfo=arr_f

end function

public sub del_table(str_tname)

obj_adox.tables.delete str_tname

end sub

public sub del_columns(arr_columns,str_tname)

set obj_tab=obj_adox.tables.item(str_tname)

if isarray(arr_columns) then

for i=0 to ubound(arr_columns)

obj_tab.columns.delete arr_columns(i)

next

else

obj_tab.columns.delete arr_columns

end if

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 obj_adox=nothing

end sub

end class

%>

public function arr_finfo(str_tname)

dim arr_f()

set obj_tadox=obj_adox.tables.item(str_tname)

for i=0 to obj_tadox.columns.count-1

set dic_info=server.createobject("scripting.dictionary")

redim preserve arr_f(i+1)

dic_info.add "name",obj_tadox.columns.item(i).name

dic_info.add "type",type_int2str(obj_tadox.columns.item(i).type)

set arr_f(i)=dic_info

set dic_info=nothing

next

arr_finfo=arr_f

end function

列出了表中所有的列名 和 屬性 

資料庫操作類

資料庫配置 return array db config array 資料庫配置 db host 127.0.0.1 伺服器地址 db name tmp 資料庫名 db user root 使用者名稱 db pwd 密碼 db encode utf8 編碼 db prefix dmtx 資料庫表字首...

資料庫操作類

using system using system.web using system.web.ui using system.web.ui.webcontrols using system.web.ui.htmlcontrols using system.data using system.data...

資料庫操作類

剛摘下來的資料庫操作類,以後再慢慢更新 using system using system.collections.generic using system.linq using system.text using system.data using system.data.sqlclient us...

php 資料庫操作類

class dbconnect if dbtable this dbchange dbtable 選擇要操作的資料庫 function dbchange dbtable type 0 返回執行完sql語句後的結果 不做處理 type 1 返回 看下面註釋 type 2 返回 看下面註釋 functi...

php資料庫操作類

config.db.php db config hostname localhost 伺服器地址 db config username root 資料庫使用者名稱 db config password 123 資料庫密碼 db config database test 資料庫名稱 db config...