ASP 3.0 advanced programming (18)

Source: Internet
Author: User
5.2.5 reference object type Library
In earlier ASP versions, when an object or component is used in a script, the public constants defined in the component (if any) are no longer valid in ASP. This means that we need to declare them (or their equivalents) and specify the corresponding values.
For example, when the ActiveX database object (ADO) component is used in earlier versions of ASP (detailed research will be conducted in chapter 8th ), you have to add the predefined constant declaration to the Open method of the record set. For example:
Const adOpenKeyset = & H0001
Const adLockPessimistic = & H0003
Const adCmdTable = & H0002
...
Rs. Open "Contact", "DSN = GlobalExampleData; UID = examples; Password = ;",_
AdOpenKeyset, adLockPessimistic, adCmdTable
...
Another method is to use the # include command to insert a file named adovbs. inc into the page. This file is provided by IIS/ASP and contains all the predefined constants required by ADO. When updating the code, you must confirm that the latest version is used and check that it is available for all page requests.
For IIS 5.0, there is a better way to add reference to the component or object type library by using the METADATA command in the HTML annotation element (IIS 4.0 does not support this function ).
<! -- Metadata type = "TypeLib"
FILE = "path_and_name_of_file"
UUID = "type_library_uuid"
VERSSION = "major_version_number.minor_version_number"
LCID = "locale_id"
-->
Where:
· Path_and_name_of_file is the absolute physical path of a type of library file (. tlb) or ActiveX DLL. You must provide this parameter or the type_library_uuid parameter.
· Type_library_uuid is the unique identifier of a database of this type. You must provide this parameter or the path_and_name_of_file parameter.
· Major_version_number.minor_version_number (optional) defines the version of the required component. If this version is not available, use the latest version.
· Locale_id (optional) is the region identifier. If no type library is found in this area, the computer uses the default (defined during installation) area.
Therefore, using this technology, you can use the following code to make the built-in ADO pre-defined constant available on the ASP page:
<! -- Metadata type = "TypeLib"
FILE = "C: Program FilesCommon FilesSystemadomsado15.dll"
-->
The file name msado15.dll can also be used for ADO components later than 2.50.
If ASP cannot load the Type Library, an error is returned and the execution of the page is stopped. Possible error messages are shown in Table 5-1:
Table 5-1 error code and description
False explanation
Description of invalid type libraries in ASP 0222
Type Library not found in ASP 0223

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.