IMDTouchKnowledge BaseShop main store

Troubleshooting

Reading WinCC Runtime Database Through the ODBC DSN

HMI and touchscreens Published 6 min read

Short answer

Yes, your application can read WinCC Runtime data: connect read-only through the User DSN the project generates, under the same Windows account that runs the runtime. Do not write into the runtime's tables — export through a managed transfer layer and import through a defined interface. The CP 443-5 that stops when the fiber ring closes is a separate PROFIBUS fault, diagnosed from its buffer before any topology change.

On this page
  1. Can my application read the WinCC Runtime database?
  2. Why does the DSN resolve in my test but not in the application?
  3. Can I write records into the WinCC database with SQL?
  4. How do I run a transfer every three minutes without losing data?
  5. How should the application open the connection so failures tell me something?
  6. Why does one CP 443-5 enter STOP when the fiber ring closes?
  7. Questions asked

Yes, you can read WinCC Runtime data from your own application — through the ODBC data source the project generates, under the Windows account that runs the runtime. The name follows the pattern CC_WinCCProjectName_DateTime_R under User DSN, and that name is the whole read path. Writing into the runtime's tables is a different transaction with a different answer, and the CP 443-5 that drops to STOP when the fiber ring closes is unrelated to either: it is a PROFIBUS and optical-topology fault that starts in the diagnostic buffer. Below: the read path, the identity trap, the write boundary, a three-minute transfer schedule with the arithmetic, and the ring commissioning order.

Can my application read the WinCC Runtime database? #

Yes, for reading: start the Runtime project, open Control Panel > ODBC Data Sources > User DSN, and point your application at the generated name CC_WinCCProjectName_DateTime_R, where the project-name and date-time parts vary with the active project.

The documented requirement is that the runtime database is addressed by its data source name — the same rule that has you specify a DSN, not a directory, when configuring where log data is stored. Two practical consequences for the reader application:

  • Discover the exact current name on the runtime machine rather than hard-coding one, because the date-time part changes with the database generation.
  • Treat the DSN as the door for reads. If you need live values rather than history, tags are the cleaner boundary, as in exchanging HMI memory data with a custom PC application.

Why does the DSN resolve in my test but not in the application? #

Because a User DSN belongs to one Windows profile: your interactive test under the login account resolves it, while a service or scheduled task running under another account cannot, on the very same machine.

The decision: run the reader under the same Windows identity that runs the WinCC Runtime project, since that account owns the generated DSN, and repeat the connection test from that identity rather than your desktop login. Two checks belong with it:

  • Open the ODBC Data Source Administrator (64-bit) and read its Drivers tab to confirm the driver your application will load is installed; the 32-bit and 64-bit administrators keep separate DSN lists, so match the application's architecture.
  • If the application must use its own account, verify which DSN scope that account can resolve before writing any connection code.

The connecting client's identity is part of the security boundary in every SCADA-to-database path — the parallel is how an Ignition Oracle connection uses JDBC trust and client identity over TLS.

Can I write records into the WinCC database with SQL? #

No: the runtime owns those tables, so third-party writes are out of contract even when the INSERT succeeds — take exports out through a managed transfer layer and bring imports in through a defined WinCC interface.

Direction decides the path:

  • Reading runtime data goes through the project DSN with read-only queries.
  • Moving WinCC data to a third-party database goes through DataXchange, the complementary product built to take WinCC information to third-party databases; the wider set of choices is covered under connecting WinCC to an external database.
  • Bringing third-party SQL records into WinCC goes through a defined import or tag interface, mapped to supported WinCC objects — never guessed internal tables.

The runtime's tables carry internal relationships, generated identifiers and cached state. A committed statement proves the database accepted it, not that the runtime did, so the decision stands even if a test insert appears to work.

How do I run a transfer every three minutes without losing data? #

Trigger one bounded transaction per 180-second interval, never start a cycle while the previous one is active, and carry the last successfully transferred timestamp so an interrupted cycle resumes without gaps or duplicates.

Worked example, with example inputs of a 3-minute interval, a worst-case exchange measured at 25 s and 400 new rows per cycle:

  • 60 min ÷ 3 min = 20 cycles per hour, and 20 × 24 = 480 cycles per day.
  • 480 × 25 s = 12,000 s = 3 h 20 min of transfer work per day, a 13.9% duty cycle (12,000 ÷ 86,400 s).
  • 180 s ÷ 25 s = 7.2 times headroom, so the interval holds even at the measured worst case.

The schedule itself changes nothing about ownership: a timer does not make an unsupported write safe. What makes the schedule sound is the guard — the scheduler refuses a new cycle while one runs, selects only rows newer than the stored watermark, and commits the destination after validation. When the records originate in the PLC rather than the WinCC archive, logging PLC data to SQL through a gateway instead of the HMI keeps that load off the operator station.

How should the application open the connection so failures tell me something? #

Open the DSN, run one read-only query, check the columns and types, close everything, and log the complete database error text — the error class, not the fact of failure, names the layer at fault.

  1. Open the connection using the discovered DSN name.
  2. Execute one read-only test query against a known table.
  3. Validate column names and data types before mapping anything.
  4. Close the result set and the connection, releasing the objects every cycle.
  5. On failure, record the full error text with a timestamp.

Read the error class this way: "data source name not found" points at the user-scope or bitness trap in the previous section, a login failure points at the authentication path, "database unavailable" or "cannot open" points at the server layer, and a syntax or invalid-object error points at your query. Release the objects on every cycle so a repeating schedule never accumulates handles.

Why does one CP 443-5 enter STOP when the fiber ring closes? #

Because closing the ring changes the live PROFIBUS topology, and a station that reacts at that instant has a configuration or wiring fault — read that CP's diagnostic buffer before touching the topology again.

This is a separate fault domain from the database work: do not rebuild the ring while debugging ODBC access, and do not change database settings to chase a bus fault. The commissioning order that finds the problem: confirm every PROFIBUS station address is unique (each CP 443-5, each CP 5413), confirm one bus profile and transmission rate network-wide, run the optical link modules as an open line until every segment communicates, then close the ring and watch which station changes state. Do the switchover with the machine in a state that tolerates a PROFIBUS interruption, because a mis-wired ring takes down every node at once.

Questions asked

Does WinCC Runtime Advanced support SQL Server Authentication directly?

No. In Runtime Advanced V17 the runtime reaches the database through the ODBC data source name only; it does not accept direct SQL Server Authentication from scripts or external applications. Build the connection on the DSN, keep credentials in the DSN's driver configuration, and test under the account that runs the runtime.

What is a File DSN and when would it help here?

A File DSN is a file that carries the complete connection definition, so any account that can reach the file by its path can use it, unlike a User DSN, which lives in one profile. Before relying on one, check the installed drivers in ODBC Data Source Administrator (64-bit) on the Drivers tab and confirm it resolves the same runtime database.

Can I point WinCC logging at a folder on another drive?

No. The log database is addressed by its data source name: during configuration you specify the DSN, not a directory, and the runtime resolves the physical location through it. To move storage, change what the DSN's driver points at, then confirm the runtime still starts and writes log data.

How can an office PC view WinCC archive data without database access?

WinCC/Dat@Monitor is the documented option: it shows current process statuses and archive data from Tag Logging and Alarm Logging on an Office PC, so viewers never touch the runtime database. Reserve DSN reads for applications that must process the records themselves.

Keep reading

  • Troubleshooting

    Why a WinCC Advanced SQL Read Script Returns Nothing

    The read script fails for faults the working INSERT never meets: a missing space turns SELECT * FROM into FROMKayitlar, a dangling ORDER BY has no column, and MoveFirst after MoveNext pins the cursor on row one. Clear them in order: DSN visible to the runtime, SQL text valid, recordset non-empty, value inside the DInt range. Each fault masks the next.

    HMI and touchscreens

  • Explainer

    Does SCADA need a master and slave PLC to run

    No. A single S7-300 with one WinCC station is a complete SCADA system for one boiler: the PLC runs control and interlocks, WinCC supervises, and web clients only display. A master and slave PLC pair is needed only when two controllers must exchange data or share one polled serial network.

    HMI and touchscreens

  • Troubleshooting

    Fixing a PCS 7 OS download that fails with SQL errors

    The transfer fails because the target-side WinCC SQL databases, the CC_* copies, stay attached to SQL Server or sit in RECOVERY_PENDING, so WinCCOM cannot replace them. Close Runtime and all editors, reboot the target, remove the obsolete CC_* databases through the SQL administration layer rather than by deleting .mdf files, delete the stale CC_OM DSN, then run one clean download.

    HMI and touchscreens