Applies To:
  • CitectSCADA 5.21

Summary:
When you are trying to set an ActiveX Object as a property of another ActiveX Object the operation will fail and Citect may crash. Consider the code below.

FUNCTION
InsertADO()
    OBJECT hADO;

    hADO = CreateControlObject("Microsoft ADO Data Control, version 6.0 (OLEDB)", "ADO", 100,500,500,530,"");
    _ObjectSetProperty(hADO, "ConnectionString", "DSN=TestDB");
    _ObjectSetProperty(hADO, "CommandType", "2");
    _ObjectSetProperty(hADO, "RecordSource", "variable");

END


The following may also be used.  The code depends on the version that is being used and should be adjusted as required.

 

FUNCTION
InsertADO()
    OBJECT hADO;

    hADO = CreateControlObject("Microsoft ADO Data Control, version 6.0 Service Pack 4 (OLEDB)", "ADO", 100,500,500,530,"");
    _ObjectSetProperty(hADO, "ConnectionString", "DSN=TestDB");
    _ObjectSetProperty(hADO, "CommandType", "2");
    _ObjectSetProperty(hADO, "RecordSource", "variable");

END

FUNCTION
InsertDBGrid()
    CreateControlObject("Microsoft DataGrid Control, Version 6.0 (OLEDB)", "DBGrid", 100, 100, 500, 480, "");

END

FUNCTION
SetGridDataSource()
   
OBJECT hADO;

    hADO = ObjectByName("ADO");
    _ObjectSetProperty(ObjectByName("DBGrid"), "DataSource", hADO);

END

When these functions are called sequentially from a page you should end up with a data control/grid combo on the page showing variable.dbf in the directory as set up in the TestDB DSN. However the _ObjectSetProperty() in SetGridDataSource() will either fail or cause Citect to crash.

N.B. You need Microsoft Visual C++ Version 6.0 or equivalent to have these controls installed on your machine.

 

Solution:
CIT has confirmed this to be a problem in Citect for Windows versions 5.20 to 5.21. This problem has been fixed in version 5.21 Service Pack F.

Keywords:
 

Attachments