TN Appsvr142 How To Query A SQL Database and Display in DataGrid View in Archestra Graphic - InSource KnowledgeCenter PDF
TN Appsvr142 How To Query A SQL Database and Display in DataGrid View in Archestra Graphic - InSource KnowledgeCenter PDF
Tech Note
Description
This article from InSource shows how to query data from a SQL database and display in a DataGrid in an Archestra Graphic.
Author: Mike Viteri
Published: 1/2/2015
Applies to: System Platform
When you want to display data from a SQL database inside an datagridview Archestra Graphic
Instructions
You will need to make sure your datagridview is imported. If not available. Please refer to this technote.
1. You will need to create an Archestra Graphic Symbol. You will need to bring in the datagrid view control and create a button.
2. Click on the button and create a action script. You will use the following script to create a connection to your SQL database.
Under sDBConnStr you will need to replace your Server, Database,UserID and Password to match your system.
For sSQL you will need to insert your query for data you want to showup in the datagrid view.
Make sure the datagridview you are using is "datagridview1" if not change the script below to make the datagridview you are using.
The complete script is pasted below in between the lines
--------------------------------------------------------------------------------------------------------------------------------------
'' Retrieve the queried elds from the query into the reader
objDR = objCmd.ExecuteReader();
Endif;
DataGridView1.AutoResizeColumns();
'' Cleanup
objDR.Close();
objDB.Dispose();
objCmd.Dispose();
objTbl.Dispose();
3. You will need to embed your symbol that has the grid and button into an Intouch Window. Go to runtime. You should see your grid
and button. when you click the button the data should be returned from the sql into the data grid.
--------------------------------------------------------------------------------------------------------------------------------------
Recommended articles
Setting up the SQL Server 2005 Express Database Changing the Default Location for New SQL Databases
Using Excel to Report on Wonderware Alarms Moving the Alarm Database to a different hard drive
Article type: Topic Articleclass: App Server TN General Article Content: Native IT Article Class: NetSuite