1. Problem Summary
Engineers running Siemens WinCC Flexible 2008 SP2 on Windows 7 (32-bit or 64-bit) frequently encounter the runtime / engineering message:
Cannot connect to configured SQL server.
The message blocks project open, project save, and translation database operations because the locally embedded Microsoft SQL Server 2005 Express (named instance WINCCFLEXEXPRESS) refuses the connection. The visible symptom is almost always a corrupt or unreadable WINCCFLEXEXPRESS user-instance data folder under the user profile, not a network or SQL Server service failure. The official Siemens recovery procedure is published in Siemens Support Entry 29420407.
2. Affected Software, Operating Systems, and Versions
| Component | Version / Build | Notes |
|---|---|---|
| WinCC Flexible 2008 | 2008 SP2 (HF7 and earlier in the field) | Engineering suite; runs with bundled SQL Server Express |
| SQL Server engine | MS SQL Server 2005 Express Edition (user-instance mode) | Launched as WINCCFLEXEXPRESS
|
| Operating system | Windows 7 Ultimate / Professional (32-bit and 64-bit) | Clean image and upgraded image both affected |
| Runtime target | Not affected by this error | Runtime panels do not use the local SQL Express instance |
WinCC Flexible 2008 reached end of marketing in 2014 and is now in the Siemens product lifecycle phase "Out of service / successor product TIA Portal". A direct upgrade path is to WinCC Comfort / TIA Portal V13+; however, the recovery procedure below restores 2008 SP2 operation without license change.
3. Symptoms and Error Messages
Typical user-reported symptoms, in the order they appear when launching WinCC Flexible 2008 SP2:
- Splash screen of WinCC Flexible opens normally.
- Project is selected or last-used project is auto-loaded.
- Modal dialog appears: "Cannot connect to configured SQL server."
- Project either fails to load or loads read-only with translation database disabled.
- SQL Server error log records
Error 15372, Severity 16, State 1when a manual connection is attempted withsqlcmdor Management Studio Express.
The Windows Application event log may also contain the Microsoft SQL Server user-instance bootstrap failure:
Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be closed.
4. Root Cause Analysis
WinCC Flexible 2008 uses a per-user instance of SQL Server 2005 Express. Each Windows account that opens WinCC Flexible gets its own binary copy and data directory stored under:
%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS
This is the standard location of a SQL Server 2005/2008 Express user-instance data directory (also referenced by the SQL Server User Instances registry key under HKCU\Software\Microsoft\Microsoft SQL Server). The contents include:
-
master.mdf/mastlog.ldf– instance-level metadata. -
tempdb.mdf– temporary database. -
model.mdf– template database. - One
.mdf/.ldfpair per project that has been opened by the user.
When the WINCCFLEXEXPRESS folder is corrupted (truncated by an antivirus quarantine, left in an inconsistent state after a Windows shutdown or BSOD, or partially overwritten by a Windows Update that updates the SQL Server native client), the user-instance process fails to attach the system databases. SQL Server 2005 returns error 15372 in this case. WinCC Flexible cannot proceed, hence the message Cannot connect to configured SQL server.
Confirmed triggers from the field:
| Trigger | Mechanism | Fix implication |
|---|---|---|
| Improper shutdown of WinCC Flex while a project is loaded | Torn write of master.mdf
|
Rebuild the user-instance folder |
Antivirus quarantine of sqlservr.exe child process |
User-instance process never starts; bootstrap fails | Exclusion list + folder rebuild |
| Windows 7 UAC virtualisation redirected writes to wrong profile path | Two WINCCFLEXEXPRESS trees, one stale |
Run as administrator + delete the stale tree |
Manual deletion of MSSQL.1 system DBs in Program Files
|
User-instance template broken | Repair SQL Server 2005 Express via MSI repair |
| Roaming profile sync conflict on terminal server | Locked .mdf file during attach |
Disable folder redirection for the SQL Data path |
5. Prerequisites for Recovery
Before executing the recovery procedure, verify the following:
- Local administrator credentials on the engineering station. WinCC Flexible writes into the user profile, but deleting files in
AppDatarequires either ownership of the folder or elevation if the files were created by a different user. - WinCC Flexible 2008 SP2 installation media or an accessible network install point, in case the SQL Server 2005 Express runtime needs to be repaired.
- A full backup of the affected WinCC Flexible project (copy the
.hmisource file and the project\s7asyscompfolder) – the procedure below does not touch project files, but conservative engineers always back up first. - Stop all SIMATIC-related services to release file handles:
net stop "WinCC flexible 2008" net stop "S7Tracesvc" - Disable resident antivirus on the engineering station during the recovery window. Add the exclusions listed in Siemens Support Entry 29420407 before re-enabling.
\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data or any folder ending in \Binn. Only the user-instance copy under %USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS must be removed.6. Step-by-Step Recovery Procedure
The procedure is the official method described in Siemens Support Entry 29420407, with the additional safety checks required on Windows 7 64-bit observed in the field.
6.1 Close WinCC Flexible and verify no process is holding the database files
- Right-click the WinCC Flexible icon in the Windows 7 taskbar and select Close window, or terminate it from Task Manager.
- Confirm the process
Siemens.Automation.Frame.exeis not listed in Task Manager → Details. - Confirm no
sqlservr.exeis running with the command:
If a staletasklist /FI "IMAGENAME eq sqlservr.exe"sqlservr.exeis listed, end it with:taskkill /F /IM sqlservr.exe
6.2 Locate the user-instance data directory
- Open Windows Explorer.
- Click in the address bar and paste the following path (Windows 7 substitutes the profile path automatically):
%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS - Verify the path resolves to a real folder, typically:
C:\Users\<username>\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS
AppData folder is hidden by default. Either enable Show hidden files, folders, and drives in Folder Options, or paste the path directly into the address bar – the latter is faster and avoids accidental navigation errors.6.3 Delete the WINCCFLEXEXPRESS folder
- Right-click the
WINCCFLEXEXPRESSfolder and select Delete. - Confirm the prompt from Windows Explorer. If Windows reports that the folder is in use, return to step 6.1 and end the offending
sqlservr.exeorSiemens.Automation.Frame.exeprocess. - Optionally empty the Recycle Bin if disk space is critical; otherwise leave the entry for safety.
Deleting the entire WINCCFLEXEXPRESS tree is safe: it contains only the per-user instance copies of the system databases (master, model, msdb, tempdb) and a per-project .mdf / .ldf pair. The master copy of the system DBs lives in the program files location, so the user instance will be regenerated from the template the next time WinCC Flexible starts.
6.4 Repair the SQL Server 2005 Express installation if required
If step 6.3 alone does not resolve the issue (typical on stations where the user has previously deleted MSSQL.1 files in Program Files), repair the SQL Server 2005 Express installation:
- Insert the WinCC Flexible 2008 SP2 DVD or mount the ISO.
- Open Control Panel → Programs and Features.
- Select Microsoft SQL Server 2005 Express Edition (WINCCFLEXEXPRESS).
- Click Uninstall/Change, then choose Repair.
- When prompted, restart the computer.
If WinCC Flexible 2008 SP2 is no longer installed (only the runtime panels remain), install Microsoft SQL Server 2005 Express SP4 from the official Microsoft distribution and apply the cumulative update. The user-instance feature is enabled by default in SQL Server 2005 Express.
6.5 Restart WinCC Flexible and let it rebuild the user instance
- Launch WinCC Flexible 2008 from the Start menu.
- Open the affected project.
- WinCC Flexible silently recreates the
WINCCFLEXEXPRESSfolder under%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\and attaches a freshly builtmaster.mdffrom the user-instance template. - The translation database and the integrated project database are regenerated.
7. Microsoft SQL Server Error 15372 In Depth
Engineers who run sqlcmd -S .\WINCCFLEXEXPRESS or open SQL Server Management Studio Express against the user instance will see:
Msg 15372, Level 16, State 1, Server .\WINCCFLEXEXPRESS
Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be closed.
Error 15372 is raised by the sqlexp*.dll bootstrap loader of SQL Server 2005 / 2008 Express. The loader tries to:
- Create the per-user data directory if it does not exist.
- Copy
master.mdf,mastlog.ldf,model.mdf,modellog.ldf,tempdb.mdf,templog.ldf,msdbdata.mdf,msdblog.ldffrom the template path into the user path. - Spawn
sqlservr.exewith the-Uand-Tflags that activate user-instance mode. - Attach the local files with a hashed instance name.
If any of the first three steps fail (corrupt template, missing mastlog.ldf, blocked sqlservr.exe), the loader returns 15372 and closes the connection. The WinCC Flexible layer translates that into the user-facing message Cannot connect to configured SQL server.
Common root causes of 15372 in WinCC Flexible 2008 environments:
| Cause | Detection | Resolution |
|---|---|---|
| Filesystem permission on the user-instance directory | ACL audit on AppData\Local\Microsoft\Microsoft SQL Server Data
|
Grant the user Full Control on the directory tree |
| Disk full | dir %USERPROFILE%\AppData\Local\Microsoft |
Free at least 1 GB on the system drive |
Antivirus blocking sqlservr.exe child process |
Process Monitor capture during launch | Add sqlservr.exe to AV exclusion list |
Corrupt template in Program Files
|
Check master.mdf size < 1.5 MB |
Repair SQL Server Express |
| Multiple Windows user accounts sharing the same profile path | Compare %USERPROFILE% between accounts |
Use distinct Windows accounts |
8. Network and Instance Configuration Checks
Although the user-instance model means a working network is not strictly required, downstream diagnostic and central-translation scenarios rely on a real SQL Server connection. The Microsoft article Fix Network-Related or Instance-Specific Errors in SQL Server lists the canonical configuration checks:
- Confirm the SQL Server Browser service is running if a named instance is in use.
- Open the SQL Server Configuration Manager and verify that TCP/IP is enabled on the desired protocols and that the listener port (default 1433) is not blocked by the Windows Firewall or a third-party firewall.
- Validate name resolution with
nslookup <server>andping -a <ip>. - Test connectivity with
telnet <server> 1433orTest-NetConnection -Port 1433in PowerShell. - Check that the local SQL Server client alias matches the instance name and that x64 / x86 aliases are configured consistently – the WinCC Flexible 2008 SP2 installation is 32-bit and uses the 32-bit client alias.
For the local WINCCFLEXEXPRESS user instance, the relevant values are:
Server name: .\WINCCFLEXEXPRESS
Authentication: Windows Authentication (integrated)
Protocol: Shared Memory (named pipes if remote)
Port: dynamic, allocated by SQL Server Browser
9. Verification After Recovery
- Open WinCC Flexible 2008 SP2 and load the affected project. The error dialog Cannot connect to configured SQL server must no longer appear.
- Open Project → Translator → Edit to confirm the translation database is reachable.
- Run Project → Compiler → Rebuild all. The compile must complete without SQL warnings.
- Open a command prompt and verify that the user instance is responding:
Expected result includes the string Microsoft SQL Server 2005 - 9.00.xxxx (xx being the service pack level).sqlcmd -S .\WINCCFLEXEXPRESS -E -Q "SELECT @@VERSION" - Confirm the recreated folder structure:
dir "%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS" master.mdf mastlog.ldf model.mdf modellog.ldf tempdb.mdf templog.ldf msdbdata.mdf msdblog.ldf - Perform a controlled shutdown of the engineering station (Start → Shut down) and relaunch WinCC Flexible to confirm the user instance is recreated cleanly on the next session.
10. Preventive Maintenance
Apply the following measures to keep the local SQL Express user instance healthy:
- Add the following directories to the antivirus exclusion list (per Siemens Support Entry 29420407):
%ProgramFiles%\Siemens\Automation\WinCC flexible 2008%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS-
%ProgramFiles%\Microsoft SQL Server\MSSQL.1(orProgram Files (x86)on 64-bit)
- Always exit WinCC Flexible via the menu Project → Exit rather than killing the process or powering off the station.
- Disable Windows 7 hybrid sleep on the engineering station; a hibernation resume that interrupts a write to
master.mdfis the single most common trigger of the corruption in the field. - Schedule a quarterly task that stops WinCC Flexible, deletes the
WINCCFLEXEXPRESSfolder, and lets it regenerate at the next launch. Automate with:schtasks /Create /SC WEEKLY /D SUN /TN "WinCCFlex UserInstance Reset" /TR "cmd /c rmdir /s /q \"%LOCALAPPDATA%\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS\"" - On terminal servers or RDP farms, ensure that the
AppDatapath is local to the session host – do not redirectAppData\Localto a network share. - Keep Windows 7 patched, but defer Windows updates that target the SQL Server 2005 native client unless approved by Siemens.
11. Escalation to Siemens Support
If the recovery procedure in Siemens Support Entry 29420407 does not resolve the issue, gather the following data before opening a Siemens Support Request (SR) via the Siemens Industry Online Support portal:
- WinCC Flexible version and service pack: Help → About.
- SQL Server version: output of
SELECT @@VERSIONon a working station. - Windows version:
winveroutput. - SQL Server error log:
%USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS\ERRORLOG. - Windows Application event log entries for
sqlservrandUserenv. - Result of
sc query WinCCflexible2008andsc query SQLWriter. - Process Monitor trace capturing the failure of
sqlservr.exeduring WinCC Flexible launch.
For legacy installations still on WinCC Flexible 2008 SP1 or earlier, request the upgrade package to SP2 from Siemens before opening an SR, because Microsoft ended mainstream support for SQL Server 2005 in 2016 and several patches are no longer available through Windows Update.
What does the WinCC Flexible 2008 error "Cannot connect to configured SQL server" mean?
It means the local Microsoft SQL Server 2005 Express user instance called WINCCFLEXEXPRESS cannot start. WinCC Flexible 2008 stores its project and translation data in a per-user instance under %USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Data\WINCCFLEXEXPRESS. When that folder is corrupted, the connection fails and the dialog appears.
Will deleting the WINCCFLEXEXPRESS folder destroy my WinCC Flexible project?
No. The folder contains only the per-user copy of the SQL Server system databases and the cached translation database. The WinCC Flexible project file (.hmi) is stored elsewhere and is not touched by the procedure. After deletion, the user instance is regenerated automatically the next time you open WinCC Flexible.
Why do I see Microsoft SQL Server error 15372 in the SQL log?
Error 15372 (severity 16, state 1) is raised by the SQL Server Express user-instance bootstrap loader when it cannot copy the master, model, tempdb, and msdb files into the user path or when sqlservr.exe fails to start. It is the underlying cause of the WinCC Flexible dialog and confirms that the user-instance data folder is the source of the problem.
Do I need to enable TCP port 1433 to fix this error?
No. The WINCCFLEXEXPRESS instance used by WinCC Flexible 2008 is a local user instance that connects over Shared Memory by default. Opening port 1433 only helps if you are trying to reach a central SQL Server for a separate application; it has no effect on the local user instance and will not resolve the dialog.
Is WinCC Flexible 2008 still supported, and what is the upgrade path?
WinCC Flexible 2008 is out of active support. Siemens recommends migrating to TIA Portal with WinCC Comfort, Advanced, or Professional. A project can be migrated from WinCC Flexible 2008 SP2 to TIA Portal V13 or later using the integrated converter, which also eliminates the local SQL Server Express dependency on the engineering station.