How to Resolve WinCC Database Context Errors and User Rights During ES to OS Project Download
In SIMATIC PCS 7 and standalone WinCC installations, the project load error 'The project could not be opened. Database context does not exist or is invalid' occurs during an Engineering Station (ES) to Operator Station (OS) download when Windows security permissions, SIMATIC user group memberships, or Microsoft SQL Server database attachments are mismatched. To resolve this, run the SIMATIC Security Controller to validate security settings, ensure matching local Windows user accounts and passwords across ES and OS nodes, verify membership in 'SIMATIC HMI' and 'SIMATIC NET' user groups, terminate hung WinCC processes with 'reset_wincc.vbs', and execute the WinCC Project Scanner to cleanly detach orphaned database files.
Table of Contents
- Architecture of WinCC Distributed Project Databases and SQL Server
- Root Causes of 'Database Context Does Not Exist or Invalid'
- Configuring Windows User Groups and SIMATIC Rights
- Step-by-Step Recovery Using reset_wincc.vbs and WinCC Project Scanner
- Comparison of Troubleshooting Tools and Resolution Methods
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Architecture of WinCC Distributed Project Databases and SQL Server
SIMATIC PCS 7 utilizes Microsoft SQL Server as the foundational relational database engine for Operator Stations. When an engineer configures an OS project on the Engineering Station (ES) and downloads it to target OS Servers or Clients:
- The project files (
<ProjectName>.mcp, database files<ProjectName>.mdf/<ProjectName>.ldf, and runtime files<ProjectName>RT.mdf/<ProjectName>RT.ldf) are transferred over the Windows network share (SMB protocol) to the destination path on the OS server. - The local WinCC database service on the target machine automatically attaches the transferred
.mdfand.ldffiles into theWINCCSQL Server instance. - If file system permissions, network access tokens, or SQL Server connection handles fail during this handshake, the project manager cannot establish context, triggering the fatal alert:
The project could not be opened. Database context does not exist or is invalid.
Root Causes of 'Database Context Does Not Exist or Invalid'
Forensic investigation identifies four distinct underlying mechanisms responsible for database context errors:
1. User Account and Credential Mismatch: The user logged into the ES does not exist on the target OS server with the exact same username and password. In non-domain (workgroup) industrial networks, pass-through authentication fails, resulting in insufficient SQL database access rights.
2. Missing SIMATIC Security Group Memberships: Windows user accounts must belong to specific local groups: SIMATIC HMI, SIMATIC NET, and SQLServer2008SQLServerUser$<ComputerName>$WINCC.
3. Orphaned Database Locks and Hung Processes: A previous WinCC runtime crash or improper shutdown left database files locked in SQL Server. When the ES attempts to overwrite or re-attach the database, SQL Server refuses access.
4. Remote Desktop Protocol (RDP) Multi-Session Conflicts: WinCC does not support concurrent multi-session RDP. If an engineer accesses the server via a non-console RDP session (mstsc /console or mstsc /admin), database access APIs become disconnected from session 0.
Configuring Windows User Groups and SIMATIC Rights
To guarantee flawless project downloads between ES and OS stations, configure the Windows security environment according to official Siemens specifications:
- Synchronize User Accounts:
* Create an identical local Windows administrator account on ES, Master OS Server, and Standby OS Server (e.g., Username:SiemensAdmin, identical complex password).
* Ensure that the password is set toPassword never expires. - Assign User Group Memberships:
* On all engineering and server nodes, openComputer Management > Local Users and Groups > Groups.
* Add the project user to the following mandatory groups:AdministratorsSIMATIC HMI(authorizes WinCC runtime and configuration tools)SIMATIC NET(authorizes OPC and Industrial Ethernet drivers)
- Execute SIMATIC Security Controller:
* From the Windows Start menu, launchSIMATIC Security Controller.
* ClickRepeat Settings. The utility will automatically configure Windows Firewall exceptions, DCOM permissions, registry security, and network sharing parameters.
* Reboot the computer once the Security Controller finishes.
Step-by-Step Recovery Using reset_wincc.vbs and WinCC Project Scanner
If an OS server displays the database context error and refuses to open or download projects, follow this recovery procedure:
- Terminate Hung WinCC Applications:
* On the target OS server, pressWindows Key + R, type:reset_wincc.vbs, and press Enter.
* Wait 60 seconds while the script gracefully closes all background SQL and WinCC processes (CCApp.exe,pdlrt.exe,s7oemax.exe). - Detach Orphaned Databases Using WinCC Project Scanner:
* Ifreset_wincc.vbsdoes not release the file locks, launch the WinCC Project Scanner tool.
* Browse to the project folder and select the<ProjectName>.mcpfile.
* The scanner detaches the.mdffiles from the SQL Server instance and cleans stale connection flags. - Manual SQL Detach (If Required):
* Open Microsoft SQL Server Management Studio (SSMS), connecting to.\WINCC.
* UnderDatabases, verify if<ProjectName>or<ProjectName>RTis listed in aPending RecoveryorSuspectstate.
* Right-click the suspect database and selectTasks > Detach...(checkingDrop Connections). - Re-Download OS Project from ES:
* In SIMATIC Manager on the ES, right-click the OS object:PLC > Download.
* Perform an Entire Download. The project will now transfer and attach cleanly.
Comparison of Troubleshooting Tools and Resolution Methods
The table below compares the primary diagnostic utilities used to resolve WinCC database context and project download failures.
Verification
To confirm that the database context issue is fully resolved:
1. In SIMATIC Manager on the ES, initiate an OS download: Target OS > PLC > Download > Entire WinCC Project.
2. Confirm that the progress bar advances through file copy, database transfer, and target station registration without error.
3. On the target OS server, open WinCC Explorer: verify that the project tree loads completely with all Graphics Designer pictures, Tag Management nodes, and Alarm Logging servers visible.
4. Activate WinCC Runtime on the OS server. Confirm that runtime initializes to 100% and displays the start screen.
5. In Windows Event Viewer and WinCC Diagnose folder (WinCC_Sys_01.log), confirm that no SQL connection or DCOM security errors are recorded.
Limitations and Operational Precautions
- Never edit, rename, or delete
.mdfor.ldffiles directly in Windows Explorer while the Microsoft SQL Server service (MSSQL$WINCC) is running. - Avoid downloading an OS project across a wireless network or high-latency VPN; packet loss during database file transfer can corrupt the master MDF database file.
- Remote Desktop (RDP) must always be launched with the
/adminswitch on client operating systems to connect to the physical console session. - Always validate final software licensing and system requirements against the applicable Siemens catalog and authorized distributor quotation.
Engineer FAQ
Why does WinCC require identical usernames and passwords in a workgroup?
Without an Active Directory Domain Controller, Windows relies on NTLM pass-through authentication. If the ES and OS do not share identical credentials, the OS denies network file access and SQL Server rejects the incoming database attachment request.
Can I delete the RT.mdf file if it is corrupted?
Yes. The RT.mdf file contains historical alarms and trend archives. If corrupted, deleting it (or creating a fresh dummy project copy) allows WinCC to recreate an empty runtime database upon the next runtime activation, though historical process logs will be lost.
What does error 'Database context does not exist' mean in SQL terms?
It means WinCC attempted to query the project configuration database using an internal ODBC/OLE-DB connection string, but the SQL Server instance has either not attached the .mdf file, has marked it 'Offline/Suspect', or denied access due to insufficient Windows permissions.
Technical References
- SIMATIC Process Control System PCS 7 Engineering Station Configuration Manual
- Siemens Industry Online Support: WinCC Project Cannot Be Opened / Database Context Error
- Siemens Industry Online Support: Using reset_wincc.vbs in SIMATIC PCS 7
Related Articles
- How to Troubleshoot Intermittent WinCC Redundancy Failures and Diagnostic Logs in SIMATIC PCS 7
- Best Practices for Backing Up and Archiving PCS 7 Multi-Projects
- How to Configure SIMATIC Rights and Security Controller for Distributed OS
Related Tags
- WinCC V7.3
- Database Context
- SQL Server
- SIMATIC Rights
- ES-OS Download