You can write this function as a function. The processing process of the function is described as follows:
Call ADODB first. the openschema function in the connection object will obtain a recordset. Each record corresponds to a table in the database, each field in the "record" contains some information about the corresponding table. The table_name field contains the name of the corresponding table.
Then, traverse the recordset. If the value of the table_name field of the "current record" is the same as the name of the table to be searched, the table to be searched exists.
The function is as follows:
CopyCode The Code is as follows: function check_gived_datatable_exist_or_not (connect_object, name_of_gived_datatable)
Do_gived_datatable_exist = false
Const adschematables = 20' indicates that you want to obtain the "table and view set" in the database"
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
Note:
After the connect_object.openschema (adschematables) function is executed, the "table and view set in the Database" is obtained. This is a data of the ADODB. recordset type.
If recordset_about_table_and_view_in_database ("table_type") = "table", the check scope is reduced to "table )".