Historian Value to InTouch Tag

Hi all, 

I want to retrieve the value (last, live) of an analog historian tag to an InTouch tag. 

A single live value, not all the column or the entire row

Those Historian tag values have been programmatically inserted to Historian 
This should not be an issue, but to keep in mind that I do not log the values using another SCADA or anything

Maybe creating a specific Access Name, or some scripting? 

Thank you in advance

Parents Reply Children
  • Dim objDB As System.Data.SqlClient.SqlConnection;
    Dim objCmd As System.Data.SqlClient.SqlCommand;
    Dim objDR As System.Data.SqlClient.SqlDataReader;
    Dim objTbl As System.Data.DataTable; 
    Dim sDBConnStr As String;
    Dim sSQL As String;
    Dim valuesArray as System.Data.DataTable;


    Text2.Text =  $DateString +" "+ $TimeString;

    sDBConnStr = "Server=labwork;Database=Runtime;User Id=sa;Password=sa;";

    ' Connect and open the database
    objDB = New System.Data.SqlClient.SqlConnection(sDBConnStr);
    objDB.Open();

    sSQL = "SELECT [Value] FROM [Runtime].[dbo].[v_AnalogHistory] Where TagName in ('Mixer100_Temperature_PV_rate_hourly','Mixer200_Temperature_PV_rate_hourly','Mixer300_Temperature_PV_rate_hourly','Mixer400_Temperature_PV_rate_hourly') and DateTime =' "+ $DateString + " " + $TimeString + "' ";

    ' Invoke the SQL command 
    objCmd = New System.Data.SqlClient.SqlCommand(sSQL, objDB);

    ' Retrieve the queried fields from the query into the reader
    objDR = objCmd.ExecuteReader();

    valuesArray= new System.Data.DataTable;
    valuesArray.Load(objDR);

    testmanualtag=valuesArray.Rows[0][0];
    testtag3=valuesArray.Rows[1][0];
    testtag_2=valuesArray.Rows[2][0];
    testtag_30067=valuesArray.Rows[3][0];

    objDR.Dispose();
    objDR.Close();
    objDB.Close();

  • Hi Dimitris, thanks for the code, this looks like it's done using Intouch scripting and SQL query, wouldn't it be better to use SQL stored procedure and then call the procedure ?