It is possible to use Processbook(VBA) to connect to get data from SQL Server and display in Textbox of Processbook.
If yes, any example to assist me.
Depending on the amount of information you need you can actually use PI-AF, if you don't have PI-AF, you can use an ODBC Dataset, and then you have PI-OLEDB. Like I said it all depends what you want to achieve. I will use a simple dataset if you only require one value from SQL. To find out more about this and a small "how to" you can go into processbook click Help->PI ProceeBook Help and in the search section insert sql, in the topic list there should be one "Create an ODBC Data Set".
to get data directly from SQL Server using VBA, you must use a MIcrosoft driver, either OLEDB or ODBC, and code it up using ADO objects or some such.
OSIsoft does provide an interface to easily send data from SQL Server to PI (and vice-versa) so that your data can be visualized using PI tags in ProcessBook. That interface is the PI Interface for Relational Database (RDBMS via ODBC). That would be a much easier solution that could be quickly leveraged across your enterprise. I would encourage you to discuss the interface with your account manager.
Also Henlo's suggestion of using PI AF is a good one. You can link the table in PI AF and display the PI AF attributes in the ProcessBook.
Thank for the reply,
Basically, I have a set of data not time-series collected at SQL server. Which need to show in Processbook.
How the processbook will work.
Why in PI processbook because there are some trend which and be easy make and view.
Here is a very simple example that I have setup in my ProcessBook to query one of my SQL tables. Please remember to add the proper references to your code for using ADODB objects. Here, I added the reference for "Microsoft ActiveX Data Objects 2.8 Library." The code runs when my "CommandButton1" is clicked. The connection string connects to my SQL server "GACHEN-AF\GACHEN_SQL" and database "SampleDB" using Windows credentials. My SQL query is provided in my TextBox1 object. I'm not really sure how you want your data displayed, so here I just have the values printing to debug.
Hope this helps!
Private Sub CommandButton1_Click()
Dim strConn As String 'Connection string'
Dim strQuery As String 'SQL query'
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SampleDB;Data Source=GACHEN-AF\GACHEN_SQL"
strQuery = TextBox1.Value
'Open the connections and run the query'
rs.Open strQuery, conn
While Not rs.EOF
'Do something with the resultset'
For i = 0 To rs.Fields.Count - 1
'Cleanup; close the connections'
Thank for the coding and explaination it work like magic.
Retrieving data ...