IV. Accessing databases across a network

advertisement
WinCC Tech Notes
1
MS Access / ODBC
________________________________________________________________________
I.
Scope of this document
This document provides an overview of the requirements for accessing
WinCC’s databases using MS Office Access 2000 from a local machine, and
across a network. It is not intended to be all-inclusive, and additional
references on the subjects covered may be necessary.
II.
Required Components
1. MS Access 2000
2. WinCC v5.0 SPI
3. User should have a working knowledge of Windows NT.
III.
Steps for Accessing WinCC’s project databases using Sybase and MS
Access 2000
Once a project has been created in WinCC, two databases are created in the
WinCC project folder: The configuration database and the Runtime database.
The configuration database is named projectname.db, and contains
configuration information for the project: Variable lists, alarm and trend
archive definitions (not data), users, channel configurations, etc.
The runtime database is named projectnameRT.db and contains runtime data
from Tag logging archives, alarm archives, and user archives.
Each database is identified by
the GUID, or Global Unique
Identifier. This GUID will be
automatically entered as a Data
Source Name on the PC where
the project was created, and is
used by other ODBC compliant
databases to access its data.
The specific GUID for a
WinCC project database can be
found in WinCC Explorer
under project properties.
An example of the Splash
projects GUID is shown here,
and corresponds to the
configuration database. The
GUID for the Runtime
database for this project would
be the same, with a capitol R
appended at the end: CC_Splash_00-07-07_09:10:37R.
________________________________________________________________________
Copyright 2000, Siemens ISBU
1
Author: Bob Meads
WinCC Tech Notes
2
MS Access / ODBC
________________________________________________________________________
To open this database from Sybase SQL Anywhere, do the following:
1. From the Windows Start menu, choose run, and enter ‘scview’
2. Connect to the WinCC database you want to view – if WinCC is open, you need
only enter the username and password: ‘dba’ and ‘sql’ respectively :
You get this dialog by using the yellow database ‘can’ icon from the menu bar in
Sybase, or using Tools -> connect.
________________________________________________________________________
Copyright 2000, Siemens ISBU
2
Author: Bob Meads
WinCC Tech Notes
3
MS Access / ODBC
________________________________________________________________________
This screenshot shows the tables
in the configuration database in
WinCC’s splash project. To see
the data, right click on the table
you are interested in, and choose
view data.
There is a SQL Command
window available that will allow
you to execute SQL commands
on the database contents, as well
as many tools you can use to
manage and export data.
To open the Runtime database,
follow the same procedure,
however from the Login Dialog,
you would press the More button,
and browse to the runtime
database in the project folder, and
enter in the same user name and
password.
If the project is single-user, you will not be able to open the runtime database while
WinCC project is activated. To do this, you will need to convert the project to Multi
User mode from the WinCC Explorer project properties.
To Open the project database in MS Access, do the following:
1. Open a blank database in MS Access
2. Go to the Tables view, and right click, choose the ‘link table’ item:
________________________________________________________________________
Copyright 2000, Siemens ISBU
3
Author: Bob Meads
WinCC Tech Notes
4
MS Access / ODBC
________________________________________________________________________
3. From the next dialog, choose Files of type: ODBC Data sources:
4. Choose the GUID of the data source you want to use:
You can choose either the Configuration or Runtime database. The GUID of the
project can be found in WinCC Explorer under Project Properties.
________________________________________________________________________
Copyright 2000, Siemens ISBU
4
Author: Bob Meads
WinCC Tech Notes
5
MS Access / ODBC
________________________________________________________________________
5. Choose the table or tables you want to link to from the next dialog:
Here, we have chosen the table where users enter comments on Alarm logging sequence
archives.
6. Next, choose which field in this table is the key field, or unique identifier:
Here, we chose to make the date/time field the key field for our table.
________________________________________________________________________
Copyright 2000, Siemens ISBU
5
Author: Bob Meads
WinCC Tech Notes
6
MS Access / ODBC
________________________________________________________________________
6. The table will now appear in your Access database, and you can read and write to
the table. Any changes you make here will be reflected in WinCC, although you
may have to refresh the view in wincc.
IV.
Accessing databases across a network:
You can use the same philosophy to access a WinCC database across a network. To do
this, you need to create a User DSN on the machine you want to access FROM, using the
ODBC 32 icon in Control Panel.
When the dialog comes up, press the Add button, and choose Sybase SQL Anywhere 5.0
driver, then choose finish.
________________________________________________________________________
Copyright 2000, Siemens ISBU
6
Author: Bob Meads
WinCC Tech Notes
7
MS Access / ODBC
________________________________________________________________________
Fill out the information on the connection dialog as shown:
Note we have used the GUID in the database name field, and browsed to the actual
database in the database file field.
Also note that we have NOT included the Database file name, and have checked network
as the option:
If you actually put the database name in this field, (i.e. MyWinCCDDRT.db) then you will
be able to access it when WinCC is not in runtime, but when runtime is activated, you
wont be able to use the DSN – you will get an error.
If you leave it blank, the reverse is true: you will be able to use the DSN only when
WinCC is in runtime, but NOT when WinCC is deactivated. If you need both, simply
create 2 DSNs, one defining the RT database, and once configured as above.
________________________________________________________________________
Copyright 2000, Siemens ISBU
7
Author: Bob Meads
Download