Author: Michael Gonzalez
Frequently Answered Questions
Miscellaneous

File Text Search & Replace Utility
HTML Text Extraction using innerText
E-mail (CDONTS.NewMail) Sample Code
SQL Server 7.0/2000

Incorporating ASP and SQL Server
100's of T-SQL Scripts
Don't Use @@ERROR with UPDATE Statements
Exporting Tables to Text Files
Creating SQL Server Databases
ASP (SQL) Query Analyzer
Increasing SQL Server Performance with Indexes
Distributed SQL Server Transactions & Queries
COM/COM+ Development
What is COM?
Isn't ActiveX and COM the same?
How can Components benefit my ASPs?
Am I using COM Components now?
How do I use COM Components in my ASPs?
Creating your First COM Component
Creating a COM Component that uses ASP Intrinsic Objects
Creating a COM Component to access an MS-Access Database
MTS Component Template
MSMQ Component Template / Example

How do I use COMs in my ASPs?

The Windows' registry is where we gain hard access to COM Components. Every COM must be registered in the registry for it to be accessed by IIS (and consequently ASPs).

To register a component, you use a command on the IIS server called REGSVR32. This command registers component information into the Windows' registry.

Suppose you wanted to register a component called com.dll. At the DOS prompt or Run... dialogue box in the Windows' Start Menu you would type:

regsvr32 C:\Path\COM.dll

...then press the Enter key. This would be the correct syntax if the component was in the C:\Path directory. Once the component is registered you should receive a message like the one below:


Now, the component is ready to use in your ASP pages. However, before you can use it, you need to know the component's programmatic identifier or ProgID. For example, in the following code the "ADODB.Connection" part is refered to as the ProgID:

Set objADO = Server.CreateObject("ADODB.Connection")

When a COM Component is created in Visual Basic, the ProgID is created in the following way:

[Project_Name].[Class_Module_Name]

To use a component in your ASP page simple create a reference to it by using the ASP Server's CreateObject method:

For example, if the component's ProgID is COM.Component, you would type:

Using VBScript:
Set objCOM = Server.CreateObject("COM.Component")
Using Javascript:
var objCOM = Server.CreateObject("COM.Component")

Remember this: an Object is not a Component (or COM Server). An Object is a reference or instance of a COM component. In this case, the object objCOM is the reference, COM is the component's server name (or COM Server), and Component is the component name (the component module with the COM Server).

Comments & Questions Form

Send It!