Resolving 'Microsoft SQL Server Cannot Access the Database' During Target OS Downloads in SIMATIC PCS 7

Resolving 'Microsoft SQL Server Cannot Access the Database' During Target OS Downloads in SIMATIC PCS 7

The error 'The project could not be opened. Microsoft SQL server cannot access the database. Please check the access rights' during an OS download from the Engineering Station (ES) occurs due to active .LCK lock files from ungracefully terminated WinCC sessions, mismatched Windows user permissions in the SIMATIC HMI group, or corrupted project database files (.mdf / .ldf). To resolve this, run reset_wincc.vbs on the target station, verify user group memberships, delete residual .lck files in the target project folder, and if necessary, perform a clean OS reconstruction on the ES followed by an Entire OS Download.

Table of Contents

Mechanism of Target OS Database Deployment

When an engineer executes PLC -> Download from SIMATIC Manager on the Engineering Station (ES) to an OS Server or OS Client:
* The ES communicates across the Terminal Bus with the target station's remote deployment service.
* It transfers the project directory, attaches the WinCC Microsoft SQL Server database (.mdf / .ldf), and registers the project in the local WinCC database catalog.
* If the SQL Server instance on the target station cannot obtain exclusive file system locks or detach existing databases, the deployment aborts with: 'Microsoft SQL server cannot access the database. Please check the access rights'.

Root Causes - Database Lock Files (.LCK) and Permission Failures

This error stems from three primary operational bottlenecks:
1. Residual .LCK Lock Files: If WinCC Runtime crashed, was terminated via Task Manager, or lost power during a previous session, a hidden lock file (e.g. <ProjectName>.lck) remains in the project directory. The lock file tells SQL Server that another process owns the database, causing attachment attempts to abort.
2. User Account and Group Permissions: The Windows user account logged into the ES must exist on the target station with an identical password, and must belong to the Administrators, SIMATIC HMI, and local SQL Server user groups.
3. Corrupted Database Logs (.ldf): If network interruptions occurred mid-download, the SQL database transaction log becomes desynchronized, preventing the database from mounting locally.

Windows Security Groups and SIMATIC Security Control

To ensure proper DCOM, firewall, and file sharing permissions across the Terminal Bus, run SIMATIC Security Control:
* On both the ES and the target OS station: Navigate to Start -> Siemens Automation -> SIMATIC Security Control.
* Click Repeat Settings; this automatically configures Windows firewall exceptions, DCOM access rights, and SQL Server network protocols required for PCS 7 downloads.

The following table summarizes target OS download checkpoints and corrective actions:

Failure SymptomUnderlying Root CauseVerification MethodCorrective ResolutionSQL Access Rights DeniedUser not in SIMATIC HMI groupWindows Computer ManagementAdd user account to SIMATIC HMI and Administrators.Database Locked / In UseOrphaned .LCK file in project directoryWindows Explorer on target OSRun reset_wincc.vbs and delete all *.lck files.Project Not Open LocallyCorrupted .ldf SQL transaction logWinCC Explorer local launchDelete target OS project folder and perform Entire Download.DCOM Communication BlockedWindows Firewall or DCOM permissionsSIMATIC Security ControlRun SIMATIC Security Control -> Select "Repeat Settings".

Step-by-Step Resolution and Project Recovery Workflow

To resolve the lock and complete the target OS download:

[Phase 1: Clear Locks on Target OS Station]
   │  • Open Command Prompt as Administrator -> Navigate to: C:\Program Files (x86)\Siemens\WinCC\bin\
   │  • Run: cscript reset_wincc.vbs  <-- Forcefully terminates orphaned SQL/WinCC processes
   │  • Open Target Project Folder -> Search for and DELETE all files ending in: *.lck
   │  • Restart the Target OS Station
   ▼
[Phase 2: Check Windows User Rights]
   │  • Open: Computer Management -> Local Users and Groups -> Groups
   │  • Verify current user is a member of:
   │      - "Administrators"
   │      - "SIMATIC HMI"
   │      - "SQLServerMSSQLUser$<MachineName>$WINCC"
   ▼
[Phase 3: Clean Target Project Directory]
   │  • If database remains corrupted: Completely DELETE the project directory on target OS
   │  • (Ensure historical archive backups are preserved if on an OS Server)
   ▼
[Phase 4: Entire OS Compile and Download from ES]
   │  • On ES: In SIMATIC Manager, right-click OS -> Compile -> Scope: Entire OS
   │  • Right-click OS -> PLC -> Download -> Scope: Entire project
   └─► Database compiles fresh, attaches cleanly, and opens without errors!

Verification

To confirm that the target OS download is functioning properly:
1. On the ES, execute an Entire OS Download; verify that the transfer progress bar completes to 100% without SQL connection error popups.
2. Log onto the target OS station; open WinCC Explorer and verify that the project opens cleanly.
3. Verify that the project title bar displays the correct computer name and project path.
4. Activate WinCC Runtime on the target station; confirm that the Graphics Runtime starts and communication tags display live data.
5. In SIMATIC Shell, verify that the target station appears with an active blue icon under the Terminal Bus network tree.

Limitations and Operational Precautions

Never delete the target OS project folder on an operational OS Server without confirming that the redundant partner server is healthy and in active runtime. Furthermore, if the server hosts historical Tag Logging or Alarm Logging archives, ensure archive segments are backed up to external storage or Process Historian before purging local project databases.

Engineer FAQ

What does reset_wincc.vbs do?

reset_wincc.vbs is an official Siemens diagnostic script that gracefully terminates hanging WinCC runtime processes (CCPerfMon.exe, PdlRuntime.exe, Script.exe) and detaches locked SQL databases.

Why does 'Project Not Open' appear when opening the project locally?

If the SQL Server instance cannot attach the database files due to missing access rights or an orphaned .lck file, WinCC Explorer cannot read the project metadata and aborts with 'Project Not Open'.

Can simple file sharing in Windows cause download failures?

Yes. Windows 'Simple File Sharing' must be disabled in Windows Folder Options. Simple file sharing forces all network connections to authenticate as Guest, preventing administrative SQL attachment.

Why is matching username and password required on ES and OS?

In workgroup environments without an Active Directory domain, Windows uses pass-through authentication. If usernames or passwords differ, DCOM and SQL authentication across the Terminal Bus fails.

Technical References

Related Articles

Related Tags

  • Target OS Download
  • SQL Access Rights
  • reset_wincc.vbs
  • .LCK Files
  • SIMATIC HMI Group
6 respuestas