WinCC.net

Home
FAQs
Downloads
Feedback

FAQs

Connecting to the WinCC database from a remote application

Introduction

WinCC uses Sybase Adaptive Server Anywhere (ASA) as it’s backend database engine. For every WinCC project, the configuration and runtime information are stored in two ASA databases.

The ASA databases are relational and open and can be accessed from any ODBC/SQL client such as Microsoft Excel or Visual Basic. This document details how to access the WinCC runtime database from an ODBC client. 

ODBC Configuration

When a WinCC project is created it automatically creates two database files, the configuration database and the runtime database.  It also creates two ODBC User Data Source Names (DSN) to point to the two database files.  The databases reside in the project directory and can be identified by their .db file extension. The DSNs can be viewed from the ODBC Data Sources Control Panel applet and shown below

ODBC Data Source Control Panel Applet

The two DSNs will be listed under the User DSN tab

ODBC Configuration & Runtime DSNs

These DSNs should be used to connect to and query the WinCC databases

The WinCC Configuration DSN is made up from the following format:

CC_Projectname_Date_Time

PART DESCRIPTION
CC Constant, Abbreviation for Control Center
Projectname the first eight characters of the project name
Date current date using format YY-MM-DD
Time current time using format HH:MM:SS

Example:  CC_WinCCPro_02-03-01_09:30:22

The Runtime DSN is identical to the above Configuration DSN but appends an ‘R’ onto the end

Example: CC_WinCCPro_02-03-01_09:30:22R

top

WinCC and ODBC client on same machine

Clients running on the same machine should use the default DSNs created by WinCC to connect to the databases. These DSNs can be found in the ODBC Data Source Control Panel applet described in the ODBC Configuration  section

top

WinCC and ODBC client on different machines

If the client is running on a remote machine, the following steps need to be carried out in order to connect to the WinCC database

  • Install Sybase ODBC Driver
  • Create ODBC Data Source to point to the WinCC database

A.  Install Sybase ASA ODBC Driver

Here is a zip file which contains all the files needed to install the ODBC Driver.  To use this zip file, extract the contents to the C: drive.  The files will automatically be extracted to C:\Program Files\sybase\SQLAnywhere7\win32.  Open the folder and run the registry file to merge the changes into the local registry.

SYBASEODBCDRIVER.ZIP

IMPORTANT:  If the files are extracted to a directory other than that listed above, it will be necessary to amend the registry file to reflect the new directory structure.

Alternatively you can manually install the driver using the following procedure.  This installation procedure can be found in the ASA Manual under the Deployment chapter. 

On the WinCC machine:

  1. Open Windows Explorer and navigate to C:\Program Files\sybase\SQLAnywhere7\win32
  2. Copy the following files to a floppy disk or onto the client machines hard disk
    • dbcon7.dll
    • dbipx7.dll
    • dblgen7.dll
    • dblib7.dll
    • dbodbc7.dll
    • dbodtr7.dll

On the Client machine:

  1. Create the directory structure C:\Program Files\sybase\SQLAnywhere7\win32
  2. Move the copied files into the above directory
  3. Open Notepad
  4. Copy the following lines into a new document

    REGEDIT4

     

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]

    "Adaptive Server Anywhere 7.0"="Installed"

     

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Adaptive Server Anywhere 7.0]

    "Driver"= "C:\\Program Files\\Sybase\\SQLAnyWhere7\\win32\\dbodbc7.dll"

    "Setup"="C:\\Program Files\\Sybase\\SQLAnyWhere7\\win32\\dbodbc7.dll"

  5. Save the file as SybaseODBC.reg in C:\Program Files\sybase\SQLAnywhere7\win32
  6. Locate the file in Windows Explorer and run it to merge the changes into the local registry

 

B.  Create ODBC Data Source to point to the WinCC database

Remote clients should connect to the WinCC database by creating an ODBC Data Source that looks directly at the database files.  Outlined below are the steps necessary to create an ODBC DSN to look at the Runtime database of a remote WinCC application.

  1. From the Control Panel open the "Data Sources(ODBC)" applet
  2. Under the System tab select the Add button
  3. Select "Adaptive Server Anywhere 7.0" from the list of drivers and hit the Finish button
  4. The Configuration Properties window will appear.  The ODBC tab should be filled in as follows:

    OPTION VALUE
    Data Source Name Enter an arbitrary name for the connection.  This name will be used by the ODBC client so it is recommended that it meaningful
    Description Enter a descriptive comment

    The "Delay AutoCommit until statement close" should be checked and the "Cursor Behaviour" should be set to "If required" as depicted below

    ODBC tab

  5. On the Login tab enter the following details:

    OPTION VALUE
    User ID dba
    Password sql

  6. On the Database tab you must specify the correct name and path to the WinCC database

    OPTION VALUE
    Server name Network name of the computer running WinCC
    Start line This should be left blank
    Database name The WinCC database name is the same as the WinCC Data Source Name.  If this name is entered incorrectly, the connection will fail
    Database file The full path to the WinCC database file.  To ensure the details are correct use the Browse button to find the database file on the WinCC machine

    The two check boxes to control automatic behaviour must be unchecked, as depicted below

    Database tab

  7. On the Network tab only the TCP/IP box should be checked and no parameters should be supplied.  As long as the client machine has network access to the WinCC computer and TCP/IP is configured correctly the connection will be made.  If you experience problems at this stage please contact the hotline on 0161 446 5545

    Network tab

  8. Switch back to the ODBC tab and select the Test Connection button.  If everything is configured correctly you should receive the message "Connection successful"

  9. The client application can now be configured to use this Data Source

 

top

2007 Salma Ghafoor