Hi there,

I am using third party ActiveX control in my application. It requires RecordSet as a input parameter to its method. I am programming my application in C#. When I call the method after creating RecordSet it throws an exception "ActiveX cannot create an object". What is the potential cause?

My code is as bellow:

// third party ActiveX object.
 DCSOCS.OCScallClass ocsCall = new DCSOCS.OCScallClass();

 ADODB.Recordset recordSet = new ADODB.RecordsetClass();
          string result = "";
        

            recordSet.Fields._Append("MIMSHOST", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("MIMSPORT", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("MIMSUSER", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("MIMSPASSWORD", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("MIMSDISTRICT", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("MIMSPOSITION", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("WorkGroup", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("EmployeeID", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("NewActivityID", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("FromActivityDate", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("ToActivityDate", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
            recordSet.Fields._Append("ChangeActInd", DataTypeEnum.adVarChar, 50, FieldAttributeEnum.adFldFixed);
           
            recordSet.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, -1);

            recordSet.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

            recordSet.Fields[0].Value = server;
            recordSet.Fields[1].Value = port;
            recordSet.Fields[2].Value = user;
            recordSet.Fields[3].Value = password;
            recordSet.Fields[4].Value = district;
            recordSet.Fields[5].Value = null;
            recordSet.Fields[6].Value =employee.Workgroup;
            recordSet.Fields[7].Value = leave.EmployeeID;
            
            recordSet.Fields[8].Value = reason.Code;
            recordSet.Fields[9].Value = leave.Start.ToString(Constants.EllipseDate);
            recordSet.Fields[10].Value = leave.End.ToString(Constants.EllipseDate);
            recordSet.Fields[11].Value = "A";
            

            try
            {
               
                result = ocsCall.UpdateRoster(ref recordSet);
                //recordSet.Close();

            }
            catch (Exception ex)
            {
                DCS.OCS.Common.Error.Log("Ellipse", ex.ToString());
                //recordSet.Close();
                return "Ellipse Error";
            }
            return result;

Check 3rd party control documentation!

There is minimul documentation from 3rd party and that just suggest use adVarchar as input parameters of fields with width of 50. and takes in RecordSet as referenced input parameter.

Is there a way to debug DLL ? To at least know what is causing problem inside 3rd party DLL. I tried looking at Exception and try to access root cause but nothing coming out of it.

Can you send me the documentation, or try to register the ocx again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.