20
wwGenericSQLGrid All Tech Notes, Tech Alerts and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information. Topic#: 001046 Created: July 2002 Updated: May 2007 Updated: July 2008 Introduction The wwGenericSQLGrid is a data access object written to operate within the InTouch ActiveX container. The object can be used for a grid representation of data from a relational database. The current release is recommended to access MS SQL Server via OLEDB. The object's appearance can be modified by the settings on the property page as well as through methods and properties at runtime. Installation is simple and takes advantage of the Window installer. The grid is installed by running the wwGenericSQLGrid.msi file that is part of the distribution package. Although this control was created specifically for use within InTouch it can be used in any suitable ActiveX container. An example of a use within InTouch might be to give an operator visibility into the customer order system allowing them to view the daily schedule. Another use might be to access recipe information and extract that data for use in the control system. Installing the wwGenericSQLGrid The wwGenericSQLGrid object should work with any version of InTouch that supports ActiveX running on any InTouch supported Operating System. This object has been installed and tested using InTouch 9.5 Patch 03 running on Windows2003 SP2. Unzip the installation files to a temporary directory. Locate the wwGenericSQLGrid.msi file. This package will be installed using the Microsoft Installer feature of Windows. Once the file is located, double-click the .msi file. Download the wwGenericSQLGrid.zip file. 1. Unzip the installation .msi file to a temporary directory. 2. Double-click the wwGenericSQLGrid.msi file within the temp directory (Figure 1 below):

Generic SQL Grid

Embed Size (px)

DESCRIPTION

Active X control for Wonderware that pulls in data from a SQL table.

Citation preview

Page 1: Generic SQL Grid

wwGenericSQLGrid

All Tech Notes Tech Alerts and KBCD documents and software are provided as is without warranty of any kind See the Terms of Use for more information

Topic 001046 Created July 2002 Updated May 2007 Updated July 2008

Introduction

The wwGenericSQLGrid is a data access object written to operate within the InTouch ActiveX container The object can be used for a grid representation of data from a relational database The current release is recommended to access MS SQL Server via OLEDB The objects appearance can be modified by the settings on the property page as well as through methods and properties at runtime

Installation is simple and takes advantage of the Window installer The grid is installed by running the wwGenericSQLGridmsi file that is part of the distribution package Although this control was created specifically for use within InTouch it can be used in any suitable ActiveX container An example of a use within InTouch might be to give an operator visibility into the customer order system allowing them to view the daily schedule Another use might be to access recipe information and extract that data for use in the control system

Installing the wwGenericSQLGrid

The wwGenericSQLGrid object should work with any version of InTouch that supports ActiveX running on any InTouch supported Operating System This object has been installed and tested using InTouch 95 Patch 03 running on Windows2003 SP2

Unzip the installation files to a temporary directory Locate the wwGenericSQLGridmsi file This package will be installed using the Microsoft Installer feature of Windows Once the file is located double-click the msi file

Download the wwGenericSQLGridzip file

1 Unzip the installation msi file to a temporary directory

2 Double-click the wwGenericSQLGridmsi file within the temp directory (Figure 1 below)

Figure 1 Double-click the wwGenericSQLGrid File Windows Installer begins the necessary steps to install wwGenericSQLGrid (Figure 2 below)

Figure 2 Windows Installer - wwGenericSQLGrid Setup

3 Click Next to continue with the installation The License Agreement Wizard appears

Figure 3 License Agreement

4 Click the I Agree option button to continue the installation process The Select Installation Folder Wizard appears

Figure 4 Installation Location

5 Specify the location where the files will be installed

6 Click Next The Confirm Installation Wizard appears

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 2: Generic SQL Grid

Figure 1 Double-click the wwGenericSQLGrid File Windows Installer begins the necessary steps to install wwGenericSQLGrid (Figure 2 below)

Figure 2 Windows Installer - wwGenericSQLGrid Setup

3 Click Next to continue with the installation The License Agreement Wizard appears

Figure 3 License Agreement

4 Click the I Agree option button to continue the installation process The Select Installation Folder Wizard appears

Figure 4 Installation Location

5 Specify the location where the files will be installed

6 Click Next The Confirm Installation Wizard appears

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 3: Generic SQL Grid

Figure 2 Windows Installer - wwGenericSQLGrid Setup

3 Click Next to continue with the installation The License Agreement Wizard appears

Figure 3 License Agreement

4 Click the I Agree option button to continue the installation process The Select Installation Folder Wizard appears

Figure 4 Installation Location

5 Specify the location where the files will be installed

6 Click Next The Confirm Installation Wizard appears

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 4: Generic SQL Grid

Figure 3 License Agreement

4 Click the I Agree option button to continue the installation process The Select Installation Folder Wizard appears

Figure 4 Installation Location

5 Specify the location where the files will be installed

6 Click Next The Confirm Installation Wizard appears

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 5: Generic SQL Grid

Figure 4 Installation Location

5 Specify the location where the files will be installed

6 Click Next The Confirm Installation Wizard appears

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 6: Generic SQL Grid

Figure 5 Confirm Installation

7 Click Next After running the installation the Installation Complete Wizard appears

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 7: Generic SQL Grid

Figure 6 Installation Complete

8 Click Close wwGenericDataGrid is now ready to use within your environment

Installing the GenericDataGrid

The GenericDataGrid can be used in any ActiveX container This grid has been written and tested within the InTouch container

Registering the GenericDataGrid Within InTouch

To install the control within InTouch you must register the control within the InTouch development environment

1 Launch InTouch WindowMaker

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 8: Generic SQL Grid

Figure 7 Launch WindowMaker

2 Select ConfigureWizardActiveX Installation

3 Select the ActiveX Control Installation tab

4 Scroll down the list until the control appears (wwGenericSQLGridgrid)

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 9: Generic SQL Grid

Figure 8 ActiveX Control Installation

5 Click Install then Close

Create a New Window for the Control

1 Create a new window within WindowMaker

2 Click the Wizard Hat icon on the toolbar

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 10: Generic SQL Grid

Figure 9 Wizard Hat ActiveX Controls

3 Double-click the Grid Control icon

4 Click OK

5 Click in the area of the window on which to place the control The control appears with its sizing handles

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 11: Generic SQL Grid

Figure 10 ActiveX Control Placement on Window

The object is ready for configuration and use

Use the Application Within an ActiveX Container

Properties

1 Double-click the control The Grid1 Properties dialog box appears

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 12: Generic SQL Grid

Figure 11 Grid Properties

The following table lists the available properties along with a description and data type

Property Name Type Description RW

ServerName String The name of the server the grid is connecting to RW

DatabaseName String The name of the database the object is connecting to RW

UserName String The user ID to be used for the connection RW

Password String The password being used for the connection RW

Caption String Sets or reads the caption from the grid object RW

FillColor Sets or reads the objects fill color RW

FillStyle Sets or reads the objects fill style RW

Font Sets or reads the grids font selection RW

MaxRecords Long Set or reads the maximum records to be returned to the grid Zero indicates all records RW

SQLString String Sets or reads the current SQL String RW

RowCount Long Reads the current row count of the grid R

EOF Boolean Read the end of file status (-1 = true 0 = false) R

Enabled Boolean Sets or reads the enabled state of the control R

BOF Boolean Read the beginning of file status (-1 = true 0 = false) R

ConnectionString String Sets or reads the value for the connection string RW

ConnectionTimeOut Long Sets or reads the value for the connection timeout RW

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 13: Generic SQL Grid

ColumnHeaders Boolean Sets or reads the value for displaying column headings RW

Methods

ActiveX control methods are similar to ActiveX control properties ActiveX control methods are accessed through ActiveX Event scripts andor InTouch QuickScripts

1 Select the Events tab

Figure 12 Events Tab Field

2 Double-click a blank cell in the Script column The ActiveX Event Scripts editor opens (Figure 13 below)

3 Select InsertActiveX

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 14: Generic SQL Grid

Figure 13 ActiveX Script Editor

The ActiveX Control Browser dialog box opens

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 15: Generic SQL Grid

Figure 14 ActiveX Control MethodProperty Browser

The following table describes the methods are available to use in a script

Method Name Return Type Description

Connect() NASelect this method when changing connection parameters Note that this method also calls the execute method to verify the connection to the database you must set the SQLString property before executing the connect

Connect()

ConnectWithString NASelect this method to connect to a data source using an ADO connection string See ADO documentation for further information on connection strings The Examples section of this Utility lists common examples

ConnectWithString(INSERT CONNECTION STRING)

Clear() NA This method will clear the grid of its current contents the recordset will still be available

Clear()

Execute() Select this method when changing the SQLString property This will execute the query and return the results to the grid

Execute()

GetRowColumnValue() String This method takes a row and column number and returns the value of that cell

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 16: Generic SQL Grid

StringTag = GetRowColumnValue(Row as int Column as int)

GetSelectedCellValue() String Returns an integer value of the selected row

IntegerTag = GetRowNumber()

GetRowNumber() LongReturns an integer value of the selected row

IntegerTag = GetRowNumber()

GetColumnNumber() Long Returns an integer value of the column the selected cell if no specific cell is selected it will return a -1

IntegerTag = GetColumnNumber()

ColumnValue() String Returns the value from the column specified in the selected row

StringTag = GetSelectedRowValue(Column as int)

MoveFirst() NA Moves the selection to the first row in the grid

MoveFirst()

MoveLast() NA Moves the selection to the last row in the grid

MoveLast()

MovePrevious() NA Moves the selection to the previous row in the grid

MovePrevous()

Movenext() NA Moves the selection to the next row in the grid

Movenest()

About() NA Displays the about box

About()

SQLStringAppend() NA Adds a string value to the SQLString property this method also pads a space at the beginning of the added string

SQLStringAppend(Where city = Boston)

Disconnect() NA Disconnects the current ADO connection

Disconnect()

PrintGrid() NA

The contents of wwGenericDataGrid are copied to the specified Excel File and then Printed to default printer

bPrint = 1 Excel File is printed to default printer

bPrint = 0 Excel File is NOT printed The user has the choice of opening the Excel file and printing it later using Excel

applPATH a string for complete path eg ldquocmyfolderrdquo If applPATH is blank ie ldquordquo the default path ldquoctemprdquo is used

FileName a string specifying the Excel filename If it is blank a default filename of ldquomyXLBook1xlsrdquo is used

PrintGrid( applPATH as String FileName as String bPrint as Boolean)

GetColumnWidth() Integer Returns column width for a given column identified by its 0-based index

IntegerTag = GetColumnWidth(Column as integer)

SetColumnWidth() NA Sets column width for a given column identified by its 0-based index

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 17: Generic SQL Grid

SetColumnWidth( SelectedColumnNumber as Integer iColWidth as Integer)

SetColumnVisible() NA Makes given Columns Visible Invisible

SetColumnVisible( ColumnIndex As Integer VisibleState As Boolean)

VisibleState = 1 makes given column visible

VisibleState = 0 makes given column invisible

GetCoulmnVisible() Boolean Returns the visibility status (Boolean) for the given Column

DiscreteTag = GetColumnVisible( ColumnIndex As Integer )

DiscreteTag = 1 means Visible

DiscreteTag = 0 means not Visible

Events

Click - This event is triggered every time the user clicks on the area of the control

SelChange - This event is triggered every time the user clicks on the row selector ie the grey area on the far left hand side of the Grid

SelectionChanged - This event is triggered when the user changes rows by clicking directly within a cell

ColumnWidthChanged - This event is triggered when the Column width is changed

These events can be used in conjunction with the methods and properties to control the behavior of the control as well as to extract data from user selections

Examples

The distribution package you received should contain an InTouch demo application that exercises all the capabilities of the wwGenericDataGrid

The following code can be run directly in InTouch quickscripts

Below is an example to connect the grid to a Database

Grid1Server = Server Grid1Database = Database Grid1UserID = UserID Grid1Password = Password Grid1Connect() Grid1PrintGrid( c myEbookxls 1)

To get a specific value from a cell

Selection = Grid1GetRowColumnValue( Row Column)

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 18: Generic SQL Grid

To get the selected value

Selection = Grid1GetSelectedCellValue()

To get the number of rows currently listed in the grid

NumberOfRows = Grid1NumberOfRows

The example above utilizes an object named Grid1 Dropping an instance of the object on a window and naming it Grid1 makes it possible to use the example exactly as it appears

Since there is no method or property to change the column headings on the grid utilize your query to accomplish this task This can be done by specifying AS with a title in your query The following is a simple example that selects the last name from the authors table and displays it as Last Name

select au_lname as Last Name from authors

The name of the column is au_lname but the grid will display it as Last Name

Connection Strings

Connection strings can be used to connect to a variety of different data sources

To connect to a data source you would use the ConnectWithString() method and pass the proper connection string For more details on connection strings check ADO documentation

The following strings are a provided for common data sources

ODBC

Provider=MSDASQL1Password=PWDPersist Security Info=TrueUser ID=UIDData Source=TheDSNInitial Catalog=THEDB

ORACLE

Provider=MSDAORA1Password=PWDUser ID=UIDData Source=OrServerPersist Security Info=True

SQLServer

Provider=SQLOLEDB1Password=PWDPersist Security Info=TrueUser ID=UIDInitial Catalog=TheDATABASEData Source=SQLServer

Jet 351

Provider=MicrosoftJetOLEDB351Password=myPWDPersist Security Info=TrueUser ID=myUIDData

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 19: Generic SQL Grid

Source=MyDBmdb

Jet 40

Provider=MicrosoftJetOLEDB40Password=myPWDPersist Security Info=TrueUser ID=myUIDData Source=CNWINDMDB

The following table lists OLE DB connection strings for several OLE DB data sources

Data Source OLE DB Connection String

Microsoftreg AccessProvider=MicrosoftJetOLEDB40Data Source=physical path to mdb file

Microsoft SQL Server Provider=SQLOLEDB1Data Source=path to database on server

Oracle Provider=MSDAORA1Data Source=path to database on server

Microsoft Indexing Service Provider=MSIDXS1Data Source=path to file

To provide for backward compatibility the OLE DB Provider for ODBC supports ODBC connection string syntax The following table lists commonly used ODBC connection strings

Data Source Driver ODBC Connection String

Microsoftreg Access Driver=Microsoft Access Driver (mdb)DBQ=physical path to mdb file

SQL Server DRIVER=SQL ServerSERVER=path to server

Oracle DRIVER=Microsoft ODBC for OracleSERVER=path to server

Microsoft ExcelDriver=Microsoft Excel Driver (xls)DBQ=physical path to xls file DriverID=278

Microsoft Excel 97Driver=Microsoft Excel Driver (xls)DBQ=physical path to xls fileDriverID=790

ParadoxDriver=Microsoft Paradox Driver (db)DBQ=physical path to db fileDriverID=26

TextDriver=Microsoft Text Driver (txtcsv)DefaultDir=physical path to txt file

Microsoft Visual FoxProreg (with a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBCSourceDb=physical path to dbc file

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use

Page 20: Generic SQL Grid

Microsoft Visual FoxPro (without a database container)Driver=Microsoft Visual FoxPro DriverSourceType=DBFSourceDb=physical path to dbf file

Technical Support

This object is provided as is and is not supported through Wonderware Technical Support A certain level of testing has been completed to ensure the control operates in the manner described in the manual but as with any add-in control no guarantees can be given as to how this object will perform within a given application It is suggested that you test your required functionality prior to deploying the control in an application

Created by B Martin Updated by Prerana Kulkarni

Tech Notes are published occasionally by Wonderware Technical Support Publisher Invensys Systems Inc 26561 Rancho Parkway South Lake Forest CA 92630 There is also technical information on our software products at Wonderware Technical Support

For technical support questions send an e-mail to supportwonderwarecom

back to top

copy2008 Invensys Systems Inc All rights reserved No part of the material protected by this copyright may be reproduced or utilized in any form or by any means electronic or mechanical including photocopying recording broadcasting or by anyinformation storage and retrieval system without permission in writing from Invensys Systems Inc Terms of Use