This chapter explains how to setup your database in FactoryStudio, using the built-in internal database or connecting to an existing external database. The following sections discuss the details:


Creating a Connection
.i.configuring:external databases;
.i.external databases:configuring;
.i.databases:configuring external;
By default, FactoryStudio uses an embedded SQL database (TatsoftDB) for the tag and alarm historians. You can configure external databases such as Microsoft SQL Server, Oracle, or others. If you expect your database to grow to more than 10 GB, you should consider using an external database.
When using the embedded database, the system automatically creates the database file. When using external databases, the database itself must already exist. However, FactoryStudio can create the tables in the database.
You can also use external databases as a data source in your application to display such things as customer or product information or to configure systems from recipes.
You must be logged in as Administrator in FactoryStudio to configure the database login and password.
To configure an external database:


Column

Description

Name

Enter a name for the database configuration. The system lets you know if the name is not valid.

Provider

Select the database provider.

Database

If options display here, select the database type.

ConnectionString

Enter the information needed to connect to the database.

LogonName

Enter a valid login name for the database.

LogonPassword

Enter the password that corresponds to the database login.

ServerIP

Enter the IP of the server of the database

Description

Enter a description for the database.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f502cdc9-aa38-4ffd-b2ce-47bf00083b9d"><ac:plain-text-body><![CDATA[

[Other columns]

For definitions of other columns that are available in many tables, see "Common Column Definitions" on page 54.

]]></ac:plain-text-body></ac:structured-macro>


The databases you create are available for use on the Tags > Historian tab, in displays, and in scripts.


Accessing Microsoft Excel
You can connect to Excel databases using an ODBC driver, an ODBC DSN, or OleDB.
Using ODBC
1. Select, then name a range of rows and columns in the worksheet. This will allow the software to read the information as a table. Choose one of the following naming processes for your version of Microsoft Excel:
For Microsoft Office 2007:
Right-click the selection then choose "Name a Range".

For Microsoft Office 2003:
In Microsoft Excel go to "Insert > Name > Define".

Name the selection (e.g., "itemsTable"). The Excel file is now ready for use.
There are several methods for communicating using ODBC:

1. In the Datasets namespace, choose "DBs" tab and create a new Provider by clicking Create new.
2. Select "Odbc Data Provider" in the "Provider" data field.
3. "Database" field choose "Microsoft Excel Database".
4. Click Ok.

5. A new row is created in the data grid, click the "ConnectionString" column.
6. In the pop-up window enter the path and the filename in the "Dbq" field.
7. Click the "Test" button to ensure that the connection is OK.
Note: "Test" is optional.

Using ODBC with a DSN
1.Go to your computer's "Control Panel", select "Administrative Tools".
2.Double-click on "Data Sources (ODBC)".

3. In the "ODBC Data Source Administrator" window click Add. You are prompted to select a driver.
4. Select the "Microsoft Excel Driver (*.xls)".
5. Click Select Workbook, then select the name of the Excel file created previously.
6. Name the Data Source, (e.g., "excelDatasource").
7. For Write access uncheck the "ReadOnly" checkbox.

8. In the Datasets namespace, choose "DBs" tab and create a new Provider by clicking Create new.
9.Under "Odbc Data Provider" options, choose "ODBC using DSN" then click Ok.
10.Click the ConnectionString column of the new row, then enter the DSN in the "DSN" field.

Using OleDB
1.In the Datasets namespace, choose the "DBs" tab.
2 Select the "OleDb data provider" option of the combo-box and create a new Provider by clicking Create new.
3.Choose "Microsoft Excel Database" then click Ok.
4.Click the ConnectionString column of the new row, then enter the path and the name of the Excel (.xls) file in the "DataSource" field.

Working with Database Tables
.i.external databases:configuring tables for;
.i.databases:configuring tables for external;
.i.tables:configuring for external databases;
If you are using an external database as a data source in your application, you can specify which table to use from the database.
To configure database tables:

Reading and writing the table contents
Runtime access to the table contents is executed automatically when the table is mapped to a DataGrid object, see "Configuring a DataGrid Window".
You can also get the table contents or perform operations on the tables, using the runtime properties for the Dataset.Table object, see http://www.tatsoft.com/help/fs-2014/runtime/index.html.
Configuring Database Queries
.i.external databases:configuring queries;
.i.databases:configuring queries for external;
.i.queries:configuring for external databases;
You can configure queries to perform more advanced functions with SQL statements to work with data from external databases.
To configure database queries:

Getting the query contents
Runtime access to the table contents is executed automatically when the query is mapped to a DataGrid object, see "Configuring a DataGrid Window" on page 155.
You can also get the query contents or perform operations on the query, using the runtime properties for the Dataset.Query object, see http://www.tatsoft.com/help/fs-2018/runtime/index.html.
Configuring Files for Data Exchange
.i.retrieving data from files;
.i.data:retrieving from files;
.i.files, configuring for data retrieval;
You can configure files to retrieve data from a network location.
To configure database files:

The Dataset Namespace
The namespace Dataset is the entry point to all objects related with the Datasets module.
The Dataset.DB object lists all configured database connections and its runtime properties
The Dataset.Table object lists all configured tables and their runtime properties
The Dataset.Query object lists the defined queries and their runtime properties.
The Dataset.File object lists the defined queries and their runtime properties.
See http://www.tatsoft.com/help/fs-2014/runtime/index.html for the complete programming reference on runtime objects.