Resolving ADODC ActiveX Errors in WinCC flexible 2008 HF3 Runtime

David Krause10 min read
HMI ProgrammingSiemensTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Resolving ADODC ActiveX Errors in WinCC flexible 2008 HF3 Runtime

Problem Overview

When integrating Microsoft ActiveX database controls (Microsoft DataGrid and ADODC — Microsoft ActiveX Data Objects Data Control) into a WinCC flexible 2008 PC Runtime project, the compiler rejects the page with the following severe error:

Error: SERIOUS ERROR: the object Control2 on page DB_View contains
inconsistent data and should be deleted

Original Italian locale message:

ERRORE grave: l'oggetto pagina Control2 nella pagina DB_View contiene
dati inconsistenti e dovrebbe essere eliminato!

The error reproduces under the following controlled test:

  • Engineering: SIMATIC WinCC flexible 2008 HF3 (Hotfix 3), patched with SP1.
  • Target: WinCC flexible Runtime (PC-based supervisor).
  • ActiveX inserted: Microsoft DataGrid Control 6.0 (SP6) and Microsoft ADODC Data Control 6.0 (SP6) on the same screen.
  • Trigger: Any non-trivial property binding — for example ConnectionString, CommandType, or RecordSource — modified through a VBScript action on the screen.

Reducing the test to a stripped-down empty PC project with only one ActiveX (for example, the Microsoft Form 2.0 ListBox) reproduces the same crash, confirming the issue is not project-specific but tied to the ActiveX container itself.

Field note: The error occurs at compile/escalation time, not at runtime. The offending ActiveX instance must be removed and reinserted, but the same fault returns once any property assignment references a database object.

Root Cause Analysis

The WinCC flexible 2008 (HF3 and SP1) runtime ActiveX container persists the design-time property bag of each inserted control in the .hmi screen file. The container expects every property of the control's COM IPersistStream / IPersistPropertyBag interface to round-trip cleanly through serialization.

The ADODC control is a Visual Basic 6.0 compatibility object. Per Microsoft's official class documentation, the ADODC class is exposed only through the Microsoft.VisualBasic.Compatibility.VB6 compatibility namespace and is intended for legacy VB6 interop, not for embedding inside third-party HMI containers:

"Provides compatibility with the Visual Basic 6.0 ADO Data Control, which enabled you to create a connection to a database using Microsoft ActiveX Data Objects…" — Microsoft.VisualBasic.Compatibility.VB6.ADODC class.

Three combined failures cause the inconsistent-data error in WinCC flexible:

  1. OCX registration mismatch: The msadodc.ocx and msdatgrd.ocx files ship with MDAC 2.8 / Windows Script Host and are not part of the WinCC flexible 2008 redistributable. Bitness mismatch (32-bit OCX loaded by 64-bit container, or vice versa) silently corrupts the property stream.
  2. License key persistence: ADODC stores an OLE licensing key as a binary blob in the property bag. WinCC flexible's serializer treats unknown binary blobs as inconsistent.
  3. DataBinding interface: ADODC requires IDataObject notification when its Recordset is replaced at runtime via VBScript. WinCC flexible 2008's screen-item wrapper does not forward these notifications, so the page is flagged as having inconsistent internal state on the next compile.

The DataGrid suffers the same serialization issue because it depends on the ADODC as a data source; if the parent ADODC state is invalid, the grid's bind state is rejected on re-load.

Affected Versions and Components

Component Tested Version Result
SIMATIC WinCC flexible 2008 HF3 (build 1.4.0.0) Error reproduces
SIMATIC WinCC flexible 2008 + SP1 1.4.0.3 Error reproduces
SIMATIC WinCC flexible 2008 + SP2 1.4.0.4 Error reproduces (no fix applied to ActiveX container)
Microsoft DataGrid Control 6.0 (SP6) msdatgrd.ocx 6.1.97.82 Property stream rejected
Microsoft ADODC Data Control 6.0 (SP6) msadodc.ocx 6.1.97.82 Property stream rejected
Microsoft Form 2.0 ListBox fm20.dll 2.0.50727 Same error class

Solution 1 — Replace ADODC with Microsoft Office Spreadsheet 11.0

The supported, Siemens-recommended substitute for displaying tabular database content inside WinCC flexible 2008 PC Runtime is the Microsoft Office Spreadsheet 11.0 ActiveX (OWC11). The component is preinstalled with Microsoft Office 2003 and is exposed as OWC11.dll.

Siemens documents this pattern in the FAQ entry Entry ID 24327008 — "How do you use the option 'Audit' / 'Option Audit' in WinCC flexible?" — Attachment 2 of which contains a complete working sample that binds an OWC11 spreadsheet to a SQL query result.

Step-by-Step — Adding OWC11 to a WinCC flexible 2008 Screen

  1. Open the WinCC flexible 2008 project and select the target screen (for example, DB_View).
  2. From the menu Tools → Controls → ActiveX Controls…, select Microsoft Office Spreadsheet 11.0 and click OK.
  3. Draw the control on the screen. The OWC11 control embeds without raising the inconsistent-data error.
  4. Open the control's properties and confirm that AllowPropertyToolbox = True and that DataType defaults are accepted.
  5. Create a new VBScript procedure bound to a screen event (e.g., OnOpen) that populates the cells from a SQL recordset using ADO directly (no ADODC control required):
    ' WinCC flexible 2008 — SQL populate of OWC11 Spreadsheet
    Dim oSS, oWB, oWS
    Dim conn, rs
    Set oSS = HmiRuntime.Screens("DB_View").ScreenItems("Spreadsheet1")
    Set oWB = oSS.Object.Worksheets(1)
    Set oWS = oWB.Cells
    
    Set conn  = CreateObject("ADODB.Connection")
    conn.ConnectionString = _
      "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
      "Persist Security Info=False;Data Source=localhost;" & _
      "Initial Catalog=DBName;"
    conn.Open
    
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open "SELECT * FROM Main", conn, 3, 3   ' adOpenStatic, adLockOptimistic
    
    ' Header row
    Dim f
    For f = 0 To rs.Fields.Count - 1
        oWS(1, f + 1).Value = rs.Fields(f).Name
    Next
    
    ' Data rows
    rs.MoveFirst
    Dim r
    r = 2
    Do While Not rs.EOF
        For f = 0 To rs.Fields.Count - 1
            oWS(r, f + 1).Value = rs.Fields(f).Value
        Next
        r = r + 1
        rs.MoveNext
    Loop
    
    rs.Close
    conn.Close
    Set rs   = Nothing
    Set conn = Nothing
  6. Compile the project. No inconsistent-data error is raised.
  7. Start the WinCC flexible PC Runtime and trigger the screen. The spreadsheet renders the SQL result set.
Deployment requirement: OWC11.dll must be registered on the target Runtime PC. Use regsvr32 OWC11.dll from an elevated command prompt. Office 2007 and later do not ship OWC11; if Office is upgraded, redistribute OWC11 from the Office 2003 package or migrate the project to WinCC (TIA Portal) V13+ which supports the native GridView control.

Solution 2 — Use ADO Directly in VBScript (No ActiveX Container)

Per Siemens entry Entry ID 26283062 — "How do you read out data from a SQL database in WinCC flexible?" — you can connect to a SQL database from inside WinCC flexible by creating the ADO objects entirely in VBScript and piping data into native HMI tags or screen items, without an embedded ADODC.

Connection String — Canonical Forms

Provider Connection String Notes
SQL Server Native (MSDASQL) Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="driver={sql server};server=localhost;database=DBName;Option=2;" Original string from the failing script; relies on ODBC driver registered as "sql server".
SQLOLEDB (OLE DB) Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=localhost Native OLE DB; no ODBC dependency.
SQLNCLI (SQL Native Client 10/11) Provider=SQLNCLI11;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=localhost Recommended for SQL Server 2008+.

Tag-Update Pattern

' WinCC flexible 2008 — read SQL row into HMI tags
Dim conn, rs
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = _
  "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
  "Persist Security Info=False;Data Source=localhost;" & _
  "Initial Catalog=DBName;"
conn.Open

Set rs = CreateObject("ADODB.Recordset")
rs.Open "SELECT TOP 1 Field1, Field2 FROM Main ORDER BY ID DESC", conn, 1, 1

If Not rs.EOF Then
    HmiRuntime.Tags("Field1").Write rs.Fields("Field1").Value
    HmiRuntime.Tags("Field2").Write rs.Fields("Field2").Value
End If

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing

This pattern avoids the ActiveX container entirely and is the documented Siemens path.

Solution 3 — Migrate to TIA Portal WinCC (Long-Term)

For new deployments, SIMATIC WinCC in TIA Portal V13 SP1 and later include a native WinCC GridView control and a proper Database Browser control that supports Microsoft SQL Server, SQLite, and ODBC datasources without ActiveX wrapping. The OWC11 dependency disappears with the move to TIA Portal.

If a project is already in WinCC flexible 2008 and migration cost is acceptable, perform the migration with the WinCC flexible Migration Tool shipped with TIA Portal. Re-test the database display after migration.

Verification Checklist

After applying Solution 1 or Solution 2, perform the following verification sequence:

  1. Compile clean: Run Project → Compile → All (Rebuild). No inconsistent-data error must appear in the output window.
  2. Simulator test: Start the WinCC flexible Simulator and navigate to the screen. The OWC11 spreadsheet must populate within 2 s on a local SQL Server.
  3. Runtime test: Start the WinCC flexible PC Runtime on the target machine. Trigger the SQL query from a button event. Confirm the data updates on each click.
  4. Stress test: Open and close the screen 20 times consecutively. The OWC11 instance must not leak memory (check with Task Manager; handle count stable within ±2).
  5. License audit: Confirm that the user account running WinCC flexible Runtime has read permission on the SQL database. Auth failures surface as runtime dialog boxes but are often mis-attributed to the ActiveX layer.

Troubleshooting Matrix

Symptom Likely Cause Corrective Action
"Contains inconsistent data and should be deleted" ADODC/DataGrid property bag rejected Remove ADODC; use Solution 1 or 2.
OWC11 control missing from ActiveX list Office 2003 not installed Install OWC11 redistributable or migrate to TIA Portal.
Runtime: "Provider cannot be found" MDAC mismatch on target PC Install MDAC 2.8 SP1 or use SQLOLEDB in connection string.
Cells display #N/A after query NULL in source column Wrap with Nz() or replace with empty string before writing to cell.
VBScript "ActiveX component can't create object" MDAC unregistered Run regsvr32 msado15.dll and re-test.
Spreadsheet loads but only header row appears adOpenForwardOnly cursor Open recordset with adOpenStatic (3) cursor type.

Common Configuration Pitfalls

  • Option=2 in ODBC extended properties translates to SQL_COPT_SS_BASE = 2 (ANSI-to-Unicode conversion enabled). Use only with SQL Server 7.0/2000; remove for SQL Server 2005+ or set explicitly to 0.
  • Persist Security Info=False is mandatory in production connection strings; True leaks the password into the screen-property stream and replicates the inconsistent-data fault.
  • CommandType = 1 means adCmdText. Values 2 (adCmdTable) and 4 (adCmdStoredProc) are valid alternatives depending on the source.
  • RecordSource must be the plain SQL string when CommandType = 1. Mixing stored-procedure names with adCmdText silently returns an empty recordset.
  • Bitness: WinCC flexible 2008 Runtime is a 32-bit process. All ActiveX and database drivers must be 32-bit. Loading the 64-bit msado15.dll will fail at CreateObject with 0x80040154.

Security and Operational Notes

SQL credentials embedded in VBScript inside a WinCC flexible project are visible to anyone with read access to the compiled *.fwx runtime file. For production systems:

  1. Use Windows Integrated Security (Integrated Security=SSPI) wherever the SQL Server and the Runtime PC share an Active Directory domain.
  2. If SQL authentication is required, read the password from an encrypted WinCC flexible user administration credential — do not hard-code it.
  3. Restrict the SQL login's permissions to db_datareader on the target database. The Runtime should never have db_datawriter or higher unless bidirectional logging is explicitly required.
  4. Enable SQL Server auditing for the login so failed attempts surface in the Windows Application event log.
Functional safety: Database display is a visualization feature only. Do not use the SQL data path for safety-relevant control logic. Safety functions must remain on the PLC scan cycle, not on a WinCC flexible VBScript event.

Related Siemens Knowledge Base Entries

  • Entry ID 24327008 — Option Audit in WinCC flexible; Attachment 2 contains the OWC11 sample.
  • Entry ID 26283062 — Reading data from a SQL database in WinCC flexible (ADO pattern).
  • Entry ID 24677043 — Additional WinCC flexible ActiveX / database integration reference.

Microsoft Compatibility Reference

The legacy ADODC control is documented under the .NET Framework 4.8.1 reference at Microsoft.VisualBasic.Compatibility.VB6.ADODC. The reference confirms that the type exists solely for Visual Basic 6.0 compatibility and is not supported inside arbitrary COM containers — confirming the practical incompatibility observed in WinCC flexible 2008.

FAQ

Why does the ADODC ActiveX raise an "inconsistent data" error in WinCC flexible 2008?

The ADODC control is a legacy VB6 COM object (msadodc.ocx) whose property bag includes a license-key binary blob. WinCC flexible 2008's screen serializer cannot round-trip this blob, so the property bag is flagged as inconsistent on every compile. The same applies to the dependent Microsoft DataGrid. Replace the ADODC with the OWC11 Spreadsheet or use ADO objects created in VBScript as documented in Siemens entry 26283062.

Which ActiveX control can replace the DataGrid in WinCC flexible 2008 HF3 PC Runtime?

Use Microsoft Office Spreadsheet 11.0 (OWC11.dll) for a tabular database display. Siemens documents a complete working sample in Attachment 2 of FAQ entry 24327008. The control is supported by Office 2003 and must be registered manually on the Runtime PC if Office is absent or upgraded.

Does WinCC flexible 2008 SP1 or SP2 fix the ADODC inconsistent-data error?

No. The error reproduces on HF3, SP1 (1.4.0.3), and SP2 (1.4.0.4). Siemens did not patch the ActiveX container; the supported workaround is to abandon the ADODC/DataGrid pair and migrate to OWC11 or ADO-in-VBScript. For new deployments, migrate to TIA Portal WinCC V13+ which provides a native GridView control.

Can WinCC flexible 2008 read directly from Microsoft SQL Server without an ActiveX?

Yes. Create ADODB.Connection and ADODB.Recordset instances with CreateObject in a VBScript action, populate internal HMI tags from the recordset, and display them via I/O fields. Siemens documents the pattern in entry 26283062. Recommended providers are SQLOLEDB.1 for SQL Server 2000/2005 and SQLNCLI11 for SQL Server 2008 and later.

What provider should I use in the SQL connection string for ADODC replacement?

Use Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=localhost for SQL Server 2000–2005. For SQL Server 2008 and later, prefer Provider=SQLNCLI11 with the same keyword layout. Avoid the MSDASQL + driver={sql server} form in production — it depends on the ODBC driver being installed on every Runtime PC and is the source of the original connection-string failure.

Back to blog