Name
CreateObjectFromClsid
Synopsis
objvar = Server.CreateObjectFromClsid(Clsid)
Returns a reference to a COM object created based on the supplied COM CLSID.
Parameters
-
objvar A variable of type Object to receive the reference to the newly created object.
-
Clsid A String variable or literal containing the COM CLSID (a type of globally unique identifier (GUID) for the component that is found in the Registry) of the desired object.
Example
The code example declares an object variable, uses Server.CreateObjectFromClsid to assign a reference to a newly created ADO Recordset object to the variable, and then opens the recordset and returns the RecordCount property to the browser using the Message label control.
Sub Page_Load( )
Dim rs1
Dim ConnString As String
ConnString = "driver={SQL Server};server=(local)\NetSDK;"
ConnString = ConnString & "database=Pubs;Trusted_Connection=yes"
rs1 = Server.CreateObjectFromClsid( _
"00000535-0000-0010-8000-00AA006D2EA4")
' 1 and 3 are the values for adOpenKeyset and adLockOptimistic
rs1.Open("SELECT * FROM Titles", ConnString, 1, 3)
Message.Text &= "There are " & rs1.RecordCount & _
" records in the Titles table.<br/>"
End SubNotes
This method is new to ASP.NET and, like the CreateObject method, it allows the late-bound use of COM components in ASP.NET applications.
The other notes relating to the CreateObject method also apply equally to the CreateObjectFromClsid method.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access