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;