Insert data to SQL using wonderware archestra

joaco1993

Lifetime Supporting Member
Join Date
Sep 2014
Location
newyork
Posts
237
Hi everyone, I would like to know if there is a way to insert data to a SQL db using archestra wonderware. I have done this using intouch “standalone” by using the bind list and some scripting inside intouch.

I would like to know if there is a way to do this but using the archestra environment.. and using some objects. The data I need to store would be information about batchs. I will receive a bit when the batch is done and when I receive it I have to send data to 6 columns.

The reason I want to do it this way is because I don’t want to have open the window viewr in order to send the data. I want to be able to send without having it open. Perhaps using some scripting with the $winplatform or $appengine..
 
thanks for answering garry, it looks intresting, however this is using UDAs. I want to insert to sql values that i have in INTOUCH tags or PLC tags.. I could not find the way to see intouch tags in the application objects scripts..

Is there anyway to do this ? to pick tags from intouch and put them in objects scripts ??

thanks again
 
Hi

I don´t know if this can help you, but take a look to this sample of SQL with Archestra. It is spanish but the syntax of Script is the same.

Regards.
 
DBLD99:

I tried using intouch:intouchtag and didnt work.

I used it in an Appengine object instance and also in an Area object instance.

The intouch tag im trying to use is: PRUBA (boolean)

and in the appengine scripts or in the area scripts i wrote:

intouch:prueba=1 , script on scan , and also tried excecute and didnt work..

any ideas ??

thanks
 
DBLD99:

I tried using intouch:intouchtag and didnt work.

I used it in an Appengine object instance and also in an Area object instance.

The intouch tag im trying to use is: PRUBA (boolean)

and in the appengine scripts or in the area scripts i wrote:

intouch:prueba=1 , script on scan , and also tried excecute and didnt work..

any ideas ??

thanks

edit: I think what you meant was in the graphics objects..
 
Microsoft SQL querys from ArchestrA script.

I use ODBC because it is portable from one pc to another. I just use custom property tags filled in with the ---. As an example "MachineTime" is a custom property. I also use Visual Studio 2010 Visual Basic to debug the code that runs in ArchestrA scripts. You just need to add the ; at the end of the statement. Also there is no using clause so the entire class name must be used.

Here is a sample that uses stored procedures to send data to a database table. This is the script that could go in a symbol script or a button script.

Dim myReader As System.Data.Odbc.OdbcDataReader;
Dim sConnString As String;
Dim oODBCConnection As System.Data.Odbc.OdbcConnection;
Dim oODBCCommand As System.Data.Odbc.OdbcCommand;
LogMessage("ODBC PutData");
sConnString = "Dsn=MyODBC;Trusted_Connection=Yes;";
oODBCConnection = New System.Data.Odbc.OdbcConnection(sConnString);
oODBCCommand = New System.Data.Odbc.OdbcCommand("{ Call PutData(?,?,?,?,?,?,?,?,?) }");

oODBCCommand.CommandType = System.Data.CommandType.StoredProcedure;
oODBCCommand.Connection = oODBCConnection;
Dim Machine As System.Data.Odbc.OdbcParameter;
Machine = oODBCCommand.Parameters.Add("@Machine", System.Data.Odbc.OdbcType.Int);
Machine.Value = MachineTime;
Machine.Direction = System.Data.ParameterDirection.Input;
Dim HydraulicPump As System.Data.Odbc.OdbcParameter;
HydraulicPump = oODBCCommand.Parameters.Add("@HydraulicPump", System.Data.Odbc.OdbcType.Int);
HydraulicPump.Value = PumpTime;
HydraulicPump.Direction = System.Data.ParameterDirection.Input;
Dim Extruder As System.Data.Odbc.OdbcParameter;
Extruder = oODBCCommand.Parameters.Add("@Extruder", System.Data.Odbc.OdbcType.Int);
Extruder.Value = ExtruderTime;
Extruder.Direction = System.Data.ParameterDirection.Input;
Dim Lube As System.Data.Odbc.OdbcParameter;
Lube = oODBCCommand.Parameters.Add("@Lube", System.Data.Odbc.OdbcType.Int);
Lube.Value = LubeCycle;
Lube.Direction = System.Data.ParameterDirection.Input;
Dim Maint24 As System.Data.Odbc.OdbcParameter;
Maint24 = oODBCCommand.Parameters.Add("@Maint24Time", System.Data.Odbc.OdbcType.Int);
Maint24.Value = Maint24Time;
Maint24.Direction = System.Data.ParameterDirection.Input;
Dim Maint120 As System.Data.Odbc.OdbcParameter;
Maint120 = oODBCCommand.Parameters.Add("@Maint120Time", System.Data.Odbc.OdbcType.Int);
Maint120.Value = Maint120Time;
Maint120.Direction = System.Data.ParameterDirection.Input;
Dim Maint480 As System.Data.Odbc.OdbcParameter;
Maint480 = oODBCCommand.Parameters.Add("@Maint480Time", System.Data.Odbc.OdbcType.Int);
Maint480.Value = Maint480Time;
Maint480.Direction = System.Data.ParameterDirection.Input;
Dim Maint2400 As System.Data.Odbc.OdbcParameter;
Maint2400 = oODBCCommand.Parameters.Add("@Maint2400Time", System.Data.Odbc.OdbcType.Int);
Maint2400.Value = Maint2400Time;
Maint2400.Direction = System.Data.ParameterDirection.Input;
Dim Maint4800 As System.Data.Odbc.OdbcParameter;
Maint4800 = oODBCCommand.Parameters.Add("@Maint4800Time", System.Data.Odbc.OdbcType.Int);
Maint4800.Value = Maint4800Time;
Maint4800.Direction = System.Data.ParameterDirection.Input;

oODBCConnection.Open();
MyReader = oODBCCommand.ExecuteReader();
MyReader.Close();
oODBCConnection.Close();

Here is the stored procedure

USE [MyDatabase]
GO
/****** Object: StoredProcedure [dbo].[PutData] Script Date: 03/08/2016 11:41:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[PutData]
-- Add the parameters for the stored procedure here
@Machine int,
@HydraulicPump int,
@Extruder int,
@Lube int,
@Maint24Time int,
@Maint120Time int,
@Maint480Time int,
@Maint2400Time int,
@Maint4800Time int


AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Update statements for procedure here
UPDATE MyDatabase.dbo.Timers SET [Machine] = @Machine, [HydraulicPump] = @HydraulicPump, [Extruder] = @Extruder, [Lube] = @Lube, [Maint24Time] = @Maint24Time, [Maint120Time] = @Maint120Time, [Maint480Time] = @Maint480Time, [Maint2400Time] = @Maint2400Time, [Maint4800Time] = @Maint4800Time WHERE DataId = 1
END

This table only has one row but you can use an INSERT IGNORE INTO for more rows. ArchestrA 10.0 needs to have an invisible graphic on screen. I use a hidden rectangle. :)
 
Thanks everyone for answering..

Trevieze, that would work yes, but i would have to have the intouch viewer opened..

I want to find a way of inserting data into sql from the Appengine Or Area objects, so there is no need to have it open ( the viewer ).

Why ? supose there is a batch running or any process and at that time i need to do some changes in the scada which is sending the data to SQL. I would miss some information during the time i am doing changes and not deployed the new app.

If I can do it using the Appengine object or any other object that i could put scripting ON SCAN or execute, then there would be no need to have the intouch viewer opened.
 
thanks for answering garry, it looks intresting, however this is using UDAs. I want to insert to sql values that i have in INTOUCH tags or PLC tags.. I could not find the way to see intouch tags in the application objects scripts..

Is there anyway to do this ? to pick tags from intouch and put them in objects scripts ??

thanks again

In application server, you do not use InTouch:IntouchTagName to link to intouch tags. You must use the absolute refernence <$InTouchViewApp instance name>:InTouchTagName. This is because Application Server may host many intouch client applications so you have to specify which one to connect to in order to read tags. InTouch:InTouchTagName can be used in archestra graphics as "InTouch:" refers to its hosting InTouch application which is a relative reference.

The Intouch application must still be active on the client though so I'm not sure if this will work for your application.
 

Similar Topics

Hi All, I need a step-by-step method to insert and update lines in the database SQL Server via software builded in FT View SE. Thanks. Fabricio
Replies
60
Views
18,855
Hello, Have a problem with the insert statement in vb.net 2010 with sql server, have my table but it keeps give me an error, attached table and...
Replies
0
Views
1,341
Is it possible to make I/O filed on HMI of POINTER data type? Pointer data type can be either temp, IN or IN_OUT variable inside FB. it would be...
Replies
1
Views
1,784
I'm new to ST so go easy. Studio 5000 L33ER PLC I'm trying to take 2 strings, merge them into 1 string. with a space between the 2 strings...
Replies
3
Views
2,259
Hello everyone. Currently I am using Eplan p8 and faced (while creating a panel) with a challenge in finding a device called DIN mounting rail...
Replies
10
Views
3,443
Back
Top Bottom