ADO Connection Passed as Variant Function Parameter
Posted on 2001-06-24
I am trying to build ASP ActiveX components which can store their own data. The client ASP script is responsible for creating an open ADO connection and then passing the Connection as a variant parameter to the component. The component in turn calls a private function to examine the "DBMS Name" property of the Connection object to determine what kind of database to talk to.
When I test out this approach, sometimes the component code reads the variant parameter as a Connection object properly and gives me the desired DBMS Name property; other times the code doesn't seem to recognize the variant as a Connection object and generates an exception with "Object required". When I use the Watch window, the expression DBConnect.Properties("DBMS Name") is evaluated as "Expression not defined in context" even when I CAN recognize and use this value. I am relatively new to VB and programming with Variants. Am I missing or violating something here?
Code for private function is:
Private Function Store(DBConnect as Variant) as Boolean
If DatabaseType = "" Then
DatabaseType = DBConnect.Properties("DBMS Connection")
Any help greatly appreciated