Check whether the ASP code of a table with a name exists in the ACCESS database.

Source: Internet
Author: User

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 )".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.