SQL to FT View Tag?

buddhaman001

Member
Join Date
Feb 2014
Location
mobile, al
Posts
52
Hello all!

I am trying to write an obtained SQL value to a Tag in Factorytalk View SE but am getting "Object Required"

I can write to the tag with "AirportPressure.Value = 10" and the sql code is pulling the correct value from the database, but I can not write it to the tag.

Code below, any help is appreciated! (I have commented the problem area towards the bottom of the snippet below)

Code:
Public UnitronicsTagsMain As TagGroup
Private Sub Display_AnimationStart()
'TagGroup
If UnitronicsTagsMain Is Nothing Then
Set UnitronicsTagsMain = Application.CreateTagGroup(Me.AreaName, 5000)
UnitronicsTagsMain.Add "APortBooster\Pressure"
End If
UnitronicsTagsMain.Active = True
Dim AirportPressure As Tag
Set AirportPressure = UnitronicsTagsMain.Item("APortBooster\Pressure")

'start SQL Connection
Dim conn As ADODB.Connection
Dim rec1 As ADODB.Recordset
Dim thisSql As String

Set conn = New ADODB.Connection
Set rec1 = New ADODB.Recordset

Dim sConn As String
  sConn = "Driver={MySQL ODBC 5.3 Unicode Driver};Trusted_Connection=No;Server=192.168.1.106;Database=test;UID=<USER>;PWD=<PASS>"
conn.Open sConn
rec1.Open "SELECT Value FROM values4convert WHERE Tag = 'Pressure'", conn

'GETTING ERROR HERE!
'this works
AirportPressure.Value = 10
'this does not
'AirportPressure.Value = rec1!Value

rec1.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
 
Try
AirportPressure.Value = rec1.field(0).Value
Or
AirportPressure.Value = rec1.fields("Value").value

Regards,
 

Similar Topics

Dear colleagues, I am reaching out for assistance with an issue I am having. I have a code that can successfully insert data from FactoryTalk...
Replies
6
Views
1,041
Hi, We are doing a project in FactoryTalk View with Database connected to SQL via Connections available within the FactoryTalk View Project. Is...
Replies
1
Views
1,576
Hi, Can someone guide me through how to use FactoryTalk SE VB script to open communication with SQL Server? which command I can use? Are there...
Replies
2
Views
2,284
Hello Every one, I need a help on vba code for getting data from MSSQL server 2014 to display in FTview SE client version 12 . Thanks. Please...
Replies
4
Views
1,804
Hello experts! Can you guide me, please, step by step how to log alarm in my scada project to Ms sql server database. In my project there is some...
Replies
2
Views
1,347
Back
Top Bottom