檢查access數(shù)據(jù)庫中是否存在某個名字的表的asp代碼
更新時間:2009年06月29日 00:06:37 作者:
首先調(diào)用adodb.connection對象中的openSchema函數(shù),這樣會得到一個Recordset,其中每一條“紀錄”對應(yīng)著數(shù)據(jù)庫中的一張表,“紀錄”的每個“字段”包含了對應(yīng)表的某方面信息。其中TABLE_NAME字段包含了對應(yīng)表的名稱
可以把本功能寫成一個函數(shù),函數(shù)的處理過程描述如下:
首先調(diào)用adodb.connection對象中的openSchema函數(shù),這樣會得到一個Recordset,其中每一條“紀錄”對應(yīng)著數(shù)據(jù)庫中的一張表,“紀錄”的每個“字段”包含了對應(yīng)表的某方面信息。其中TABLE_NAME字段包含了對應(yīng)表的名稱
然后遍歷這個Recordset,如果“當(dāng)前紀錄”的TABLE_NAME字段的值和要查找的表的名字一樣,證明要查找的表存在。
函數(shù)如下所示:
function check_gived_DataTable_exist_or_not(connect_object,name_of_gived_DataTable)
Do_gived_DataTable_exist=false
Const adSchemaTables=20 '表明想要得到數(shù)據(jù)庫中“表(table)和視圖(view)的集合”
set RecordSet_about_table_and_view_in_DataBase=connect_object.openSchema(adSchemaTables)
Do Until RecordSet_about_table_and_view_in_DataBase.EOF
if RecordSet_about_table_and_view_in_DataBase("TABLE_TYPE")="TABLE" then
if RecordSet_about_table_and_view_in_DataBase("TABLE_NAME")= name_of_gived_DataTable then
Do_gived_DataTable_exist=true
exit do
end if
end if
RecordSet_about_table_and_view_in_DataBase.movenext
Loop
check_gived_DataTable_exist_or_not=Do_gived_DataTable_exist
end function
注釋:
connect_object.openSchema(adSchemaTables)這個函數(shù)執(zhí)行后,會得到“數(shù)據(jù)庫中表(table)和視圖(view)的集合”,這是一個ADODB.Recordset類型的數(shù)據(jù)。
if RecordSet_about_table_and_view_in_DataBase("TABLE_TYPE")="TABLE"這句話把檢查范圍縮小為“表(table)”。
首先調(diào)用adodb.connection對象中的openSchema函數(shù),這樣會得到一個Recordset,其中每一條“紀錄”對應(yīng)著數(shù)據(jù)庫中的一張表,“紀錄”的每個“字段”包含了對應(yīng)表的某方面信息。其中TABLE_NAME字段包含了對應(yīng)表的名稱
然后遍歷這個Recordset,如果“當(dāng)前紀錄”的TABLE_NAME字段的值和要查找的表的名字一樣,證明要查找的表存在。
函數(shù)如下所示:
復(fù)制代碼 代碼如下:
function check_gived_DataTable_exist_or_not(connect_object,name_of_gived_DataTable)
Do_gived_DataTable_exist=false
Const adSchemaTables=20 '表明想要得到數(shù)據(jù)庫中“表(table)和視圖(view)的集合”
set RecordSet_about_table_and_view_in_DataBase=connect_object.openSchema(adSchemaTables)
Do Until RecordSet_about_table_and_view_in_DataBase.EOF
if RecordSet_about_table_and_view_in_DataBase("TABLE_TYPE")="TABLE" then
if RecordSet_about_table_and_view_in_DataBase("TABLE_NAME")= name_of_gived_DataTable then
Do_gived_DataTable_exist=true
exit do
end if
end if
RecordSet_about_table_and_view_in_DataBase.movenext
Loop
check_gived_DataTable_exist_or_not=Do_gived_DataTable_exist
end function
注釋:
connect_object.openSchema(adSchemaTables)這個函數(shù)執(zhí)行后,會得到“數(shù)據(jù)庫中表(table)和視圖(view)的集合”,這是一個ADODB.Recordset類型的數(shù)據(jù)。
if RecordSet_about_table_and_view_in_DataBase("TABLE_TYPE")="TABLE"這句話把檢查范圍縮小為“表(table)”。
相關(guān)文章
PostHttpPage用asp是實現(xiàn)模擬登錄效果的代碼
PostHttpPage用asp是實現(xiàn)模擬登錄效果的代碼...2007-09-09asp+javascript實現(xiàn)404頁的處理轉(zhuǎn)換
用404來來解決頁面路徑的變換的方法2008-06-06JavaScript在ASP頁面中實現(xiàn)掩碼文本框效果代碼
在網(wǎng)頁中輸日期、時間、IP地址等需要一定的格式限制,否則將會程序?qū)茈y和程序溝通2012-08-08P3P 和 跨域 (cross-domain) cookie 訪問(讀取和設(shè)置)
在IE 里面跨域去設(shè)置 cookie跨域的實現(xiàn),嘗試了n中方法都不行,查了一下資料,可以通過設(shè)置header中的p3p值來實現(xiàn),真不錯:)2009-06-06實現(xiàn)UTF8轉(zhuǎn)換GB2312國標(biāo)碼的asp代碼
ASP來實現(xiàn)UTF8轉(zhuǎn)換GB2312國標(biāo)碼-GB2312轉(zhuǎn)UTF-8,需要的朋友可以參考下。2010-04-04使用innerHTML時注意處理空格和回車符(asp后臺處理)
innerHTML中如果包含空格和回車都會被認為是段落的結(jié)束,造成程序運行出錯,解決辦法,輸出的時候?qū)⒖崭窈突剀囂鎿Q掉,方便js調(diào)用。2011-08-08