The OLD DB Provider Samples

About the Samples

Historian OLE DB provider includes samples from various applications that demonstrate some possible applications of the provider. Use these reports directly or modify them to fit your requirements. They are provided as examples, and are not the only way of creating reports in the specified clients. The sample reports are located in the subfolders of the Historian\Samples folder.

The following list outlines the applications for which samples are included:

Note: You must specify a server name or enter a login username and password when you connect to the Historian server from these applications. For instance, in ADO you pass the server name, username, and password in the connect string.

Crystal Reports Samples

You can find the Crystal Reports v8.0 Professional samples in the Historian\Samples\Crystal folder. The following table outlines the sample reports included in this folder.

Table 1. Crystal Reports Samples
File NameDescription
SimpleCrystal80Report.rptReport showing values cast from Variant to Float.
MultipleServersSubreport.rptReport that retrieves data from two servers by using a subreport.
iFIX1_CHART_OLEDB.rptReport from the iFIX Sample System converted from the iFIX Historical ODBC driver to OLE DB.
iFIX1_CROSSTAB_OLEDB.rptReport from the iFIX Sample System converted from the iFIX Historical ODBC driver to OLE DB.
iFIX1_DAILY_OLEDB.rptReport from the iFIX Sample System converted from the iFIX Historical ODBC driver to OLE DB.

Use the Crystal Reports Samples

Open any of the sample Crystal Reports in Crystal Reports v8.0 Professional. The following figure shows the SimpleCrystal80Report.rpt file, which reports the value, quality, and timestamp of Historian tags.

Figure: Sample Crystal Report

Changing the Server Name

About this task
Make sure that you change the Historian Server name to point directly to your Historian server, so that the report generates correctly in Crystal Reports. By default, this server name is T20.
Procedure
  1. Open the report file in Crystal Reports.
  2. Select the Database menu.
  3. If the Database menu does not appear automatically, follow these steps
    1. Wait for approximately 90 seconds for the connection timeout to occur.
      After the 90-second timeout, the Data Link Properties window appears. Although it may appear as if Crystal Reports has stopped working or is frozen before the timeout occurs, this functionality is as expected.
    2. Change the Data Source field.
      You can leave this field empty to use the default Historian server or enter a specific Historian server name.
    3. Select OK.
    4. Skip step 4.
  4. If the Database menu appears automatically, follow these steps:
    1. Select Set Location from the Database menu.
      The Set Location window appears.
    2. Select Set Location.
      The Data Explorer appears.
    3. Select a source and select Set.
    4. Select Done.

Microsoft Excel Samples

You can find the Microsoft Excel samples in the Historian\Samples\Excel folder. The following table outlines the samples included in this folder.

Table 2. Microsoft Excel Samples
File NameDescription
ihOLEDB_ LASTHOUR.XLSOne-sheet report that uses auto-refresh to display the last hour of data using relative shortcuts.
ihTags.odcData source file that retrieves the ihTags table from the default server.
iHistorian.udlSample universal data link (.UDL) file that connects to the default Historian server with the currently logged-in user.

Opening the Sample Excel Report

Procedure

  1. Open Microsoft Excel.
  2. Select Open from the File menu.
    The Open window appears.
  3. Select the ihOLEDB_LASTHOUR.XLS file in the Historian\Samples\Excel folder and select Open.
    The sample report opens, as shown in the following figure.
    Figure: Sample Excel Report

Using the Sample .ODC File

Procedure

  1. Open Microsoft Excel.
  2. Select Open from the File menu.
    The Open window appears.
  3. Select the ihTags.odc file in the Historian\Samples\Excel folder and select Open.
    The sample report opens, as shown in the following figure.
    Figure: Sample Excel Report Using the .ODC File
  4. To update the data in this display, select the Refresh button on the External Data toolbar.
    • To view the External Data toolbar if it is not available, select Toolbars from the View menu, and then select External Data.

Importing Data Using the Sample .UDL File

About this task

With the sample universal data link (.UDL) file, you can specify the connection information so that Excel can connect to the tables in Historian OLE DB provider and import data using the default server and the currently logged-in user.

Procedure

  1. Open Microsoft Excel.
  2. From the Data menu, select Import External Data, and then select Import Data.
    The Select Data Source window appears.
  3. Select the Historian.udl file in the Historian\Samples\Excel folder, and then select Open.
    The Select Table window appears.
  4. Select the table that you want to query, and then select OK.
    The Import Data window appears.
    Note: If you want to run a SQL command instead of the default table command setting, refer to Edit SQL Queries in Excel.
  5. Select OK to import the column data from the selected table.
    Historian data populates the current spreadsheet.

iFIX and VisiconX Sample

You can find the iFIX sample picture with the VisiconX controls in the Historian\Samples\iFIX folder. The name of the sample in this folder is HistoricalAnimation.grf.

Note: To use iFIX with VisiconX, you may have to edit your FixUserPreferences.ini configuration file. Refer to Updating FixUserPreferences.ini for more information.

Opening the iFIX Sample Picture

Procedure

  1. Copy HistoricalAnimation.grf to your Dynamics/Pic folder.
  2. Start iFIX.
  3. Open the iFIX WorkSpace, if not already open.
  4. Double-click the Pictures folder in the iFIX WorkSpace tree.
  5. Double-click the HistoricalAnimation picture to open the picture in the WorkSpace.
    The picture appears, as shown in the following figure.
    Figure: iFIX Screen With VisiconX Controls
  6. Experiment with the sample:
    • Try switching between the configure and run modes.
    • Follow the steps on the picture.
    • Try editing the picture.
    • View the properties of the VisiconX controls.
    • Change the properties.
    Note: You can have multiple VisiconX controls that each link to different Historian servers.

Create a Background Schedule to Run Crystal Reports

In iFIX, you can create a background schedule that runs Crystal reports. Sample Visual Basic code to perform this function is detailed below:

Private ReportFileName
Private CrystalReport

Private Sub KKTimer_OnTimeOut(ByVal lTimerId As Long)

Set CrystalApplication = CreateObject("Crystal.CRPE.Application")
Set CrystalReport = CrystalApplication.OpenReport("C:\Program Files (x86)\GE\iFIX\APP\RTtemplate.rpt") CrystalReport.Printout False

Set CrystalReport = Nothing
Set CrystalApplication = Nothing
End Sub

Visual Basic and ADO Samples

You can find the Visual Basic and ADO samples in the Historian\Samples\VB folder. The following table outlines the samples included in this folder.

Table 3. Visual Basic and ADO Samples
File NameDescription
SimpleADOExample.vbpVisual Basic project file that uses a simple ADO example with a connect string.
modSimpleADOExample.basFile that is part of the SimpleADOExample.vbp project file.
iholedb_databoundgrid.vbpVisual Basic project file that displays a data-bound grid example that fetches data from the ihRawData table.
frmMain.frmFile that is part of the iholedb_databoundgrid.vbp project file.
frmMain.frxFile that is part of the iholedb_databoundgrid.vbp project file.