可以把本功能寫成一個函數(shù),函數(shù)的處理過程描述如下:
首先調(diào)用adodb.connection對象中的openSchema函數(shù),這樣會得到一個Recordset,其中每一條“紀(jì)錄”對應(yīng)著數(shù)據(jù)庫中的一張表,“紀(jì)錄”的每個“字段”包含了對應(yīng)表的某方面信息。其中TABLE_NAME字段包含了對應(yīng)表的名稱
然后遍歷這個Recordset,如果“當(dāng)前紀(jì)錄”的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
新聞熱點(diǎn)
疑難解答
圖片精選