WinCC Flexible 2008 SP2 on SQL Server 2008 R2: VB Compile Fix

David Krause14 min read
HMI / SCADASiemensTroubleshooting
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

WinCC Flexible 2008 SP2 on SQL Server 2008 R2 Express: Resolving the "Error in Line -1, Column 1" VB Script Fault

This reference addresses a documented configuration conflict between Siemens WinCC Flexible 2008 SP2 + Hotfix 13 and Microsoft SQL Server 2008 R2 Express (instance build 10.5.x) co-resident on a Visual Studio 2010 development workstation. The conflict produces a hard "Error in line -1, column 1" when compiling or adding VBScript to a project, plus a secondary "Installed SQL Server is newer — is not possible to open project" rejection during project open. Both behaviors are caused by the WinCC Flexible 2008 internal SQL major-version probe, not by the database compatibility level of the attached MDF.

1. Problem Overview

Engineers migrating Windows XP / Windows 7 HMI engineering stations to current Microsoft data stacks frequently hit the exact symptom chain below on a Siemens SIMATIC HMI engineering workstation:

  1. Microsoft Visual Studio 2010 (or any SQL-using IDE) installs SQL Server 2008 R2 Express, creating instance version 10.5.x, SQL Writer VSS 10.5, and the SQL Server Browser service.
  2. The WinCC Flexible 2008 SP2 + Hotfix 13 installer is launched on the same workstation.
  3. The WinCC Flexible setup detects the pre-existing newer SQL Writer (10.5) and aborts its bundled SQL Server 2005 Express (major version 9) install path.
  4. The operator manually removes SQL 2005 (if it was partially staged), uninstalls any prior WinCC Flexible and WinCC Flexible Runtime, deletes the WINCCFLEXEXPRESS data directory, and reinstalls WinCC Flexible 2008 SP2 + Hotfix 13 cleanly.
  5. On first project open or rebuild, the dialog "Installed SQL Server is newer — is not possible to open project" stops the operation.
  6. Setting the project database to SQL Server 2005 compatibility mode (compatibility_level 90) on the SQL 2008 R2 server is ignored — WinCC Flexible inspects the server major version, not the database compatibility level.
  7. Any attempt to add or rebuild a VBScript in the editor terminates with "ERROR IN LINE -1, COLUMN 1" with no source-line attribution.

2. WinCC Flexible 2008 SP2 Architecture

WinCC Flexible 2008 SP2 consists of two cooperating components that both touch the local SQL instance:

Component Function SQL Interaction
WinCC Flexible 2008 ES (Engineering System) Project editor, compiler, downloader Creates, attaches, and reads the WINCCFLEXEXPRESS MDF for compile, rebuild, and script edit operations.
WinCC Flexible Runtime / Simulator (RT) Panel runtime on the engineering station Reads tag archive, alarm logs, and scripts from the same MDF at panel start.

The default integration data directory for the project/integration database is the WINCCFLEXEXPRESS folder installed under the Siemens Automation program tree (typically %ProgramFiles%\Siemens\Automation\WinCC flexible\WINCCFLEXEXPRESS on x64 Windows). The folder holds the project MDF/LDF pair that the engineering station attaches to the local SQL instance when a project is opened.

WinCC Flexible 2008 SP2 was qualified and released against SQL Server 2005 Express (major version 9). The WinCC Flexible 2008 host-binding code was not updated in any subsequent hotfix to recognise major versions 10+ (SQL Server 2008 / 2008 R2) or 11+ (SQL Server 2012). Hotfix 13 was the last public English build of the 2008 SP2 branch.

3. Root Cause: Hard-Coded SQL Major-Version Probe

The fault is not a database compatibility issue but a setup-time and runtime version probe. Inside the WinCC Flexible service layer, the host extracts the SQL Server major version from SELECT @@VERSION (or the equivalent SNI/SQLSRV API call) and compares it against the constant 9. Two failure paths exist:

Probe Result WinCC Flexible 2008 SP2 + HF13 Behavior
Major = 9 (SQL 2005 Express, 9.00.x) Accepted. Project open, compile, and runtime bind proceed normally.
Major = 10 (SQL 2008 / 2008 R2) or higher Project open is rejected with "Installed SQL Server is newer — is not possible to open project." The script editor subsequently stops with "ERROR IN LINE -1, COLUMN 1" because the schema-bound Scripte table fails to populate.

This probe is independent of T-SQL database compatibility level. Setting compatibility_level 90 (SQL 2005) on a 2008 R2 server controls only the query optimiser behaviour for that database — the WinCC Flexible host check reads the server major version, not the database flag, so compatibility mode is silent on this fault.

4. The "Error in Line -1, Column 1" Symptom Explained

The "Line -1, Column 1" message is a parser-handle failure reported by the WinCC Flexible script editor, not a VBScript syntax error. In all observed cases on WinCC Flexible 2008 SP2 + HF13 it has three contributing causes:

  • The WINCCFLEXEXPRESS MDF could not be attached because the SQL attach probe returned "newer version" and aborted the project bind before the Scripte table was populated.
  • The 32-bit Microsoft VBScript engine registration was disturbed when SQL Server 2008 R2 setup ran on an x64 Windows host (or when SP2 / Hotfix 13 were applied out of order). The WinCC Flexible script editor requires a 32-bit VBScript COM registration; native 64-bit registration in HKLM\SOFTWARE\Microsoft\VBScript only is not enough on a 32-bit ES process.
  • The WinCC Flexible COM host registration in HKCR\CLSID for the script editor component is missing because the installer's SQL-stage skipped when SQL 2005 could not be staged, leaving dependent COM registrations uninstalled.
Standard fix paths documented for generic Windows Script Host failures (re-registering vbscript.dll, scrrun.dll, jscript.dll) only correct symptoms 2 and 3. They do not satisfy symptom 1, the SQL major-version probe. Attempting them on a SQL Server 2008 R2 instance will still leave the project unable to open.

5. Compatibility Matrix

SQL Server Build Major Version WinCC Flexible 2008 SP2 + HF13 Status Field Notes
SQL Server 2005 Express SP3 / SP4 9.00.x Supported Original qualification target; bundled with WinCC Flexible 2008 installer.
SQL Server 2008 (non-R2) Express 10.00.x Rejected — "newer version" Same probe applies; HF13 does not extend support.
SQL Server 2008 R2 Express (SP0 / SP1 / SP2 / SP3) 10.50.x Rejected Conflict scenario described in this article; bundled SQL Writer 10.5 blocks bundled SQL 2005 install.
SQL Server 2012 Express 11.00.x Rejected Same probe; further out of scope.
SQL Server 2014 / 2016 / 2017 / 2019 / 2022 Express 12+ Rejected Out of scope for WinCC Flexible 2008.

6. Solution Path A — Side-by-Side Named SQL Instances

The supported coexistence path installs SQL Server 2005 Express into a uniquely named instance while leaving the existing SQL Server 2008 R2 Express instance untouched. Each instance runs under its own service account and binds its own dynamic port, so the two engines do not collide.

Prerequisites

  • Local administrator on the engineering workstation.
  • WinCC Flexible 2008 SP2 + Hotfix 13 installer media.
  • SQL Server 2005 Express SP4 setup media. SP4 is the highest released build of the 2005 branch (9.00.5000) and does not bump the major version; SP3 (9.00.4035) is also acceptable.
  • Minimum 2 GB free disk for the additional instance log + data directories.

Step-by-Step

  1. Open services.msc and stop SQL Server (SQLEXPRESS), SQL Server VSS Writer (10.5), and SQL Server Browser for the existing 10.5 instance. Leave the service Startup Type at Manual so development tools can re-enable them later.
  2. Launch the SQL Server 2005 Express installer. On the "Instance Name" page, choose Named Instance and enter a non-default name, for example WINCCFLEX. The default instance SQLEXPRESS remains the 2008 R2 engine for Visual Studio.
  3. On the "Authentication Mode" page, choose Mixed Mode and set the sa password. Record it in the project handover binder — WinCC Flexible 2008 reads the SQL credentials from the registry on first project open.
  4. After install completes, confirm both instances are reachable: sqlcmd -S .\WINCCFLEX -E (Windows auth on the 2005 instance) returns the 1> prompt; run SELECT @@VERSION and verify the result contains 9.00. followed by the SP4 build number.
  5. Launch WinCC Flexible 2008 ES installer. When the installer prompts for the SQL target, point it to .\WINCCFLEX. If the dialog is auto-detecting, let the installer create the WINCCFLEXEXPRESS folder under the default location.
  6. Apply WinCC Flexible 2008 SP2, then Hotfix 13 in that exact order.
  7. Reboot and verify that no "newer SQL Writer" warning appears at login.
  8. Open a known-good project. The "newer SQL Server" dialog must not appear, and the script editor must accept new VBScript without the "Line -1, Column 1" fault.
Do NOT edit the registry value HKEY_LOCAL_MACHINE\SOFTWARE\Siemens\Automation\WinCC flexible SQL connection sub-key to point the WinCC Flexible host to the 10.5 instance. The major-version probe runs as the first action in the connection path and will fail-fast regardless of the connection string used.

7. Solution Path B — Virtualisation and Dual Boot

If side-by-side instances continue to fail, isolate WinCC Flexible 2008 from the SQL 2008 R2 stack entirely.

Option B.1 — Hyper-V / VMware Workstation / VirtualBox Virtual Machine

  1. Provision a Windows 7 SP1 x86 (32-bit) or x64 VM with 2 vCPU, 4 GB RAM, and a 60 GB virtual HDD.
  2. Join the VM to the same Active Directory domain as the engineering workstation if TIA Portal project migration is anticipated.
  3. Install only SQL Server 2005 Express SP4 + WinCC Flexible 2008 SP2 + HF13 in the VM. Do not install Visual Studio 2010 or any side-by-side SQL 2008 R2 components inside this VM.
  4. Snapshot the VM immediately before any panel commissioning cycle so that a rebuild can be rolled back in seconds.

Option B.2 — Dual Boot

  1. Shrink the OS partition using Disk Management, or install a second physical disk dedicated to WinCC Flexible.
  2. On the WinCC partition install only Windows + SQL 2005 Express + WinCC Flexible 2008 SP2 + HF13. Leave SQL 2008 R2 on the Visual Studio partition.
  3. Use the BIOS boot menu (or bcdedit) to select the WinCC partition when commissioning/downloading to panels; boot to the VS partition for application development.
Neither path requires an additional Siemens licence seat. WinCC Flexible 2008 is licensed per workstation or per USB licence dongle, not per host machine identity, so the VM install activates against the same licence as a physical install.

8. Solution Path C — Connection-String Override (Last-Resort, Unsupported)

Editing the WinCC Flexible connection string in the registry (the ConnectionString sub-key under HKLM\SOFTWARE\Siemens\Automation\WinCC flexible) has been observed to bypass the project-open version probe in isolated tests, allowing the MDF to attach manually via SQL Server Management Studio. This path is documented for completeness only. Field-observed limitations include:

  • Bypasses the ES project-open probe but does not bypass the runtime major-version probe at panel start.
  • Allows attaching the MDF and rebuilding legacy project binaries, but breaks the signed-image path used by panel transfer and HMI download to SIMATIC panels.
  • Will not survive a WinCC Flexible SP/HF reinstall because the registry key is re-written by the installer.

Treat this as a "save the deadline" path only. Open a Support Request at the Siemens industrial support portal and plan to re-image the workstation when the project is delivered.

9. Pre-Installation Checklist

Check Command / Action Expected Value
Existing SQL instances reg query "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server" /s List each installed instance name and major version.
SQL Writer service version sc query "VSS" or services.msc > SQL Server VSS Writer properties 10.5 build blocks SQL 2005 setup.
VBScript engine registration reg query "HKCR\CLSID\{B54F85AA-5637-4610-A0E6-3D6E6DDEB9E1}" Must resolve; 32-bit view on x64 OS lives in Wow6432Node.
Free disk on system drive Explorer > This PC > System drive properties > 2 GB remaining after both instance installs.
WinCC Flexible build Help > About WinCC Flexible (in the editor) 2008 SP2 + HF13 (build 13.0.0.0).
OS edition and bitness winver WinCC Flexible ES is 32-bit; on x64, the 32-bit VBScript DLLs must be present.

10. Verification Procedure

  1. Open the project that previously produced the "newer version" dialog. The dialog must not appear. If it does, re-verify that the WinCC Flexible host is pointing to the named 9.x instance (e.g. .\WINCCFLEX) and not to the 10.5 default instance.
  2. In the project navigator, right-click Scripts > New VBScript, name the script, and place SmartTags("Tag_01") = SmartTags("Tag_01") + 1 on line 1. Right-click > Compile. The output panel must report 0 errors / 0 warnings; the "Line -1, Column 1" message must not appear.
  3. Run Project > Rebuild All. The build log must enumerate all tag, alarm, and script objects without SQL provider errors.
  4. Launch WinCC Flexible Runtime with simulator. Verify tag simulation, alarm acknowledgement, and that the new VBScript executes. Stop the RT.
  5. Open SQL Server Management Studio on the 10.5 instance and confirm that no WINCCFLEXEXPRESS database is attached there. The MDF must remain attached to the 9.x instance only. Cross-check with SELECT name FROM sys.databases executed against each instance.
  6. Re-register the 32-bit VBScript engine as a precaution: %windir%\SysWOW64\regsvr32.exe vbscript.dll (on x64) or %windir%\System32\regsvr32.exe vbscript.dll (on x86). Both should return "success."

11. Known Field Observations

  • WinCC Flexible 2008 SP2 + Hotfix 13 was the final public English Hotfix and did not extend SQL Server support past major version 9. Subsequent Siemens releases migrated to WinCC (TIA Portal) where SQL Server 2008 / 2012 / 2014 are supported.
  • Install order matters. The clean sequence is: SQL 2005 named instance → WinCC Flexible 2008 → SP2 → HF13. Installing SP2 / HF13 over a missing SQL 2005 layer leaves the script-editor COM component unregistered and reproduces "Line -1, Column 1" even after SQL 2005 is later added.
  • On 64-bit Windows the WinCC Flexible ES remains a 32-bit process (the WinCCES.exe binary). Confirm that only the 32-bit OLE DB provider for SQL 2005 (and not the 64-bit build) is registered in HKLM\SOFTWARE\Wow6432Node\Microsoft SQL Server.
  • UAC must be disabled (or the engineering user must run the editor elevated) when the WINCCFLEXEXPRESS folder sits under Program Files; otherwise the editor cannot update the MDF and silently reverts, mimicking an SQL fault.
  • The Microsoft SQL Server 2008 R2 SP2 - Express Edition package (download identifier 30438) is the canonical 10.5 installer that Visual Studio prerequisites and many third-party ISV setups expect; do not replace it with a newer Express build mid-flight.

12. Diagnostic Reference Matrix

Symptom Likely Cause Resolution
"Installed SQL Server is newer" Major-version probe rejects 10.x Move the project to a SQL 2005 named instance; never edit the connection string to point at 10.x.
"ERROR IN LINE -1, COLUMN 1" Script editor cannot read the Scripte table Verify the 9.x MDF attach succeeds; re-register 32-bit VBScript DLLs; re-install ES in the correct sequence.
Setup abort: "newer SQL Writer" SQL Writer 10.5 already installed Stop SQL Writer service during install, or use the side-by-side named instance path.
Compile succeeds but RT fails at start RT is pointed at the wrong instance Open the WinCC Flexible control panel applet and retarget the runtime database connection to the 9.x instance.
MDF attach raises error 948 Database compatibility_level 100 stuck on a 9.x server Re-create the database on the 9.x instance; do not migrate the MDF directly from 2008 R2, or script schema and data instead of detach/attach.
VBScript edit immediately resets UAC writing protection on the data folder Run the editor elevated, or relocate the WINCCFLEXEXPRESS folder to a writable path before opening the project.

Why does WinCC Flexible 2008 reject a SQL Server 2008 R2 instance even when the database itself is in 2005 compatibility mode?

WinCC Flexible 2008 connects to the SQL instance and reads the major version token from @@VERSION (or the equivalent SNI response) before any project tables are touched. This version (9, 10, 11, …) is compared against a constant in the WinCC Flexible host binding. Database compatibility level is a parser-level setting tuned with ALTER DATABASE … SET COMPATIBILITY_LEVEL = 90 (or via sp_dbcmptlevel) and is never read by the version probe, so a 2008 R2 database configured to compatibility 90 still fails the project-open dialog.

Can SQL Server 2005 Express and SQL Server 2008 R2 Express coexist on the same Windows 7 workstation?

Yes. Install each engine as a Named Instance with a distinct identifier (for example SQLEXPRESS for the 2008 R2 engine and WINCCFLEX for the 2005 engine). Confirm coexistence with sqlcmd -L from each instance — both must enumerate. Service accounts, TCP ports, and the VSS Writer instance do not conflict as long as the instance names differ.

What does "ERROR IN LINE -1, COLUMN 1" mean in the WinCC Flexible VBScript editor?

It is a parser-handle failure from the script editor, reported when the editor cannot load the project's VBScript source rows from the Scripte table — typically because the MDF failed to attach to a SQL instance during project open. It is not a VBScript syntax error and does not point to a real source line; WinCC Flexible line numbers are 1-based, so -1 indicates that the source buffer was never populated.

Is WinCC Flexible 2008 SP3 or SP4 the right build to use with SQL Server 2008 R2?

No. WinCC Flexible 2008 SP3 and SP4 are post-2008 SP2 refresh builds that retain the SQL Server 2005 Express dependency. The last public English build of the branch remains WinCC Flexible 2008 SP2 + Hotfix 13 (build 13.0.0.0). If SQL Server 2008 R2 (or newer) support is required for ongoing engineering, migrate the project to TIA Portal WinCC (Comfort / Professional) where SQL Server 2008 / 2012 / 2014 are fully supported.

How do I escalate this issue to Siemens officially?

Open a Support Request through the official Siemens Industrial Online Support portal (support.industry.siemens.com). Include the WinCC Flexible build number (Help > About), the SQL instance version output from SELECT @@VERSION, the Windows edition and bitness, and the exact wording of the "newer SQL Server" dialog. Attach the project archive (.zfp) if release permits. Siemens engineering will confirm whether the constellation is officially released for your product branch and provide either a fix or a migration path to TIA Portal.

Back to blog