Citect - DataGrid - SQL

ayhan

Member
Join Date
Jan 2011
Location
istanbul
Posts
2
Hello,

I've been researching since this morning, but i havent managed to fix my problem yet.

I store all my events in SQL Database. I would like to see all my events in a DataGrid in Citect.

Is there anyone can help me out?

SQL 2008 Express Edition
Vijeo Citect v7.2
 
Are you using the Citect's Database Exchange Manager? have configured connection to your SQL database and successfully tested it? Then all data should be shown in runtime
 
I managed to connect an ADO Data Control object to the database, but i couldnt make the connection between ADO Data Control and DataGrid.

is it possible to connect an ADO Data Control object to a Datagrid?
 
Could you make this connection?

I managed to connect an ADO Data Control object to the database, but i couldnt make the connection between ADO Data Control and DataGrid.

is it possible to connect an ADO Data Control object to a Datagrid?


Microsoft ADO Data Control 6.0 Does Not Connect to My SQL???

Microsoft ADO Data Control 6.0 Does Not Connect to My SQL???
Can someone help me because my Adodc is not communicating to my SQL pack?

1 - My factorytalk 8.0 when I fetched the Object - Active Control - Microsoft ADO Data Control 6.0 - gave me an error - License to install this I installed Microsoft Studio Visual Basic 6.0

2 - Done This I searched again for my Microsoft ADO Data Control 6.0 and my DataGrid.
I do all his configuration looking for the Bank to squeeze table in Test as if it had everything ok.

Does anyone know what may be happening that I can not connect it to my SQL?

Script Grid Inicializaca.jpg
 
I have just written this in VB.net and works fine, maybe you could sort out your problem. Notice the use of a data adapter & dataset.

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str As String = "dsn=MyTest;uid=sa;pwd=''"
Dim Conn1 As New Odbc.OdbcConnection(str)
'Dim Conn1 As New SystemData.Odbc.connection
Dim SQLString As String = "SELECT Tag_1, Tag_2, Tag_3, Tag_4 FROM Tag_Table"
Dim Rs1 As New Odbc.OdbcDataAdapter()
Dim ds As New DataSet
Rs1 = New Odbc.OdbcDataAdapter(SQLString, Conn1)
Conn1.Open()

Rs1.Fill(ds, SQLString)
'Display the data in the grid
DataGridView1.DataSource = ds.Tables(0)

End Sub

DataGrid.png
 
Good morning friend, I still could not communicate my ADO Data Control with my SQL Bank or communicate my DataGrid with my Adodc.

I didn't even find this Objects from my Activex Control before. After I installed Visual Studio Basic 6 I was able to find them, but they don't communicate with my bank. Neither doing the setting themselves and not via script.

If you know anything I can do thank you !!!

I am trying to create it via Visual Basic 6.0 the ADO Control Data and my DataGrid. They communicate with each other and communicate via sql bank all right too. I export it .OCX to register in my factorytalk, but when I click on the grid I can not throw the value of the tags for my supervision. I'm guessing that is the way to declare my variables, because in connection with it is only the left arrows would have to be bidirectional. Do you know how I declare in my Visual Basic to be my two-way variables?

Tela DataGrid Scritp - 10.jpg DataGrid Scritp - 10.jpg Supervisorio - 10.jpg
 
As far as I can see you have not opened the connection.
You have dim Adodc as ADODB connection but you have not opened it
 
As far as I can see you have not opened the connection.
You have dim Adodc as ADODB connection but you have not opened it



This was created in Studio visual basic 6.0 and then registered with factorytalk.

What else should I do to be able to communicate this ADO DataControl with my bank and communicate it with my DataGrid later?

Supervisorio - 10.jpg
 
As far as I can see you have not opened the connection.
You have dim Adodc as ADODB connection but you have not opened it

By FactoryTAlk I was not able to make the connection of DataControlADO with the database, so I risked doing in Visual Studio Basic 6.0 and then export it to .OCX and register in FactoryTalk objects, but I can not pass the values ​​of my variables of my Grid for Factory internal tags.

I don't know which way to run !!! :(
 
As I said before I do not know FT but I have used Movicon and used the in-built grid, however, Movicon is great at connecting to databases but I struggled to get the Grid control to work, my answer was to connect to the DB using basic only & not configuring it in the ocx, The Datagrid in VB.net is different than in .net as it uses different techniques to connect ADODB is considered old now, however, I did find that it does still contain the older connections for backward compatibility. If you can connect to the DB using VB (I believe you already have from previous posts then connect in the same way, put it into a record set then use that to populate the grid
Rs1.Fill(ds, SQLString)
'Display the data in the grid
DataGridView1.DataSource = ds.Tables(0)

Then you would have to reverse it to write them back, however, someone on this forum with FT experience must have done this before.
 
Last edited:
I have just written this in VB.net and works fine, maybe you could sort out your problem. Notice the use of a data adapter & dataset.

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str As String = "dsn=MyTest;uid=sa;pwd=''"
Dim Conn1 As New Odbc.OdbcConnection(str)
'Dim Conn1 As New SystemData.Odbc.connection
Dim SQLString As String = "SELECT Tag_1, Tag_2, Tag_3, Tag_4 FROM Tag_Table"
Dim Rs1 As New Odbc.OdbcDataAdapter()
Dim ds As New DataSet
Rs1 = New Odbc.OdbcDataAdapter(SQLString, Conn1)
Conn1.Open()

Rs1.Fill(ds, SQLString)
'Display the data in the grid
DataGridView1.DataSource = ds.Tables(0)

End Sub


This script is not looking for my table values ​​for my variables.
If you can help me, I thank you.

This plays the values ​​for my slq table - Works perfectly.

Can you help me fix the script that searches my SQL tag?

TELA - Script Busca e Joga Valor para o SQL.jpg
 
You have not put in Conn1.Execute SQLString in the top one so it has not executed the query that's why you don't have any data
Also you do not have a recordset to put the data in then you need to make your tags = the recordset.
However if you have multiple entries in the database then you will need to select recordset indexes as you will have an array of (4,x) i.e. Recordset(0,0) RecordSet(0,1) and so on.
 
Last edited:
You have not put in Conn1.Execute SQLString in the top one so it has not executed the query that's why you don't have any data
Also you do not have a recordset to put the data in then you need to make your tags = the recordset.
However if you have multiple entries in the database then you will need to select recordset indexes as you will have an array of (4,x) i.e. Recordset(0,0) RecordSet(0,1) and so on.

---------------------------------------
Good morning buddy, I added the Conn2.Execute SQLString line as you said, but still it's not pulling me bank information for my
- NumericDisplay1

Is there a way to edit my script as you said to help me and make it work once and for all?

---------------------------------------
Private Sub Button1_Released()

'Conecta com o DNS32_Script Criado no Administrativo Tools - Data Source (ODBC) - odbcad32.exe
Conn2.ConnectionString = "dsn=DSN32_Script;uid=sa;pwd=!ntecnial2014**;"

'Seleciona na tabela criado dentro do banco, no da tabela (Tabela_Tags)
SQLString = "SELECT TesteTag1, TesteTag2,TesteTag3,TesteTag4 FROM Tabela_Tags"
Conn2.Open
Conn2.Execute SQLString

Me.Elements("NovoNumericDisplay1").Value = TesteTag1
Me.Elements("NovoNumericDisplay2").Value = TesteTag2
Me.Elements("NovoNumericDisplay3").Value = TesteTag3
Me.Elements("NovoNumericDisplay4").Value = TesteTag4

Conn2.Close
Set Conn2 = Nothing

Exit Sub
Err:

End Sub
 
I will try to modify your code as I see it, however, I do not understand how you have not dimensioned Conn2 perhaps that works in FT

Private Sub Button1_Released()
'Added this as in vb you need to dimension a record set
Dim Rs1 As New ADODB.Recordset
Dim Conn2 as New ADODB.Connection

'Conecta com o DNS32_Script Criado no Administrativo Tools - Data Source (ODBC) - odbcad32.exe
Conn2.ConnectionString = "dsn=DSN32_Script;uid=sa;pwd=!ntecnial2014**;"

'Seleciona na tabela criado dentro do banco, no da tabela (Tabela_Tags)
SQLString = "SELECT TesteTag1, TesteTag2,TesteTag3,TesteTag4 FROM Tabela_Tags"
Conn2.Open
' Open the connection to move records into the Record Set
Rs1.Open SQLStr,Conn1,,,
' Rem this out for now as we have opened it with the record set
'Conn2.Execute SQLString (make this a comment for now)
' Move to the first record set
Rs1.MoveFirst
' set the values in the elements to the record set fields
Me.Elements("NovoNumericDisplay1").Value = Rs1.Fields(0).Value
Me.Elements("NovoNumericDisplay2").Value = Rs1.Fields(1).Value
Me.Elements("NovoNumericDisplay3").Value = Rs1.Fields(2).Value
Me.Elements("NovoNumericDisplay4").Value = Rs1.Fields(3).Value

Conn2.Close
Set Conn2 = Nothing
Set Rs1 = Nothing

Exit Sub
Err:

End Sub
It seems there is some difference in FT so above is a bit of a guess.
Below is mine in Movicon and it works

Dim Rs1 As New ADODB.Recordset
Dim Conn1 As New ADODB.Connection
Dim SQLStr As String
Conn1.ConnectionString = "dsn=Names;uid='sa';pwd='';"
SQLStr = "SELECT Tag_1, Tag_2, Tag_3, Tag_4 FROM Tag_Table"
Conn1.Open
Rs1.Open SQLStr,Conn1,,,

Rs1.MoveFirst
Me.Elements("NovoNumericDisplay1").Value = Rs1.Fields(0).Value
Me.Elements("NovoNumericDisplay2").Value = Rs1.Fields(1).Value
Me.Elements("NovoNumericDisplay3").Value = Rs1.Fields(2).Value
Me.Elements("NovoNumericDisplay4").Value = Rs1.Fields(3).Value

Rs1.Close
Set Rs1 = Nothing
Conn1.Close
Set Conn1 = Nothing
 
Bah did as you said there now everything is working perfectly, is throwing the values ​​of my table to my fields.

All I need now is for him to throw the last values ​​in it, he's always getting the first one with MoveFirst
and if I use MoveLast it's giving me syntax error.

----------------------------
Private Sub Button1_Released()

'Conecta com o DNS32_Script Criado no Administrativo Tools - Data Source (ODBC) - odbcad32.exe
Conn2.ConnectionString = "dsn=DSN32_Script;uid=sa;pwd=!ntecnial2014**;"
Conn2.Open

'Seleciona na tabela criado dentro do banco, no da tabela (Tabela_Tags)
'SQLString = "SELECT TesteTag1, TesteTag2,TesteTag3,TesteTag4 FROM Tabela_Tags ORDER BY TesteTag1 DESC"
SQLString = "SELECT TesteTag1, TesteTag2,TesteTag3,TesteTag4 FROM Tabela_Tags "

'Abre a Conexao para mover os registros
Rs1.Open SQLString, Conn2

'Move para o primeiro conjunto de registros da tabela SQL
Rs1.MoveFirst

'Passa o Valor dos campos para o ME.Elements que estao criados na Tela
Me.Elements("NovoNumericInput1").Value = Rs1.Fields(0).Value
Me.Elements("NovoNumericInput2").Value = Rs1.Fields(1).Value
Me.Elements("NovoNumericInput3").Value = Rs1.Fields(2).Value
Me.Elements("NovoNumericInput4").Value = Rs1.Fields(3).Value

Conn2.Close
Set Conn2 = Nothing
Set Rs1 = Nothing

Exit Sub
Err:

End Sub
 

Similar Topics

Hello, I have a running project on Citect v5.42 and simatic net v6.4 I have created a new spare PC and loaded all software like Citect, station...
Replies
0
Views
68
Hello everyone, In a factory where we installed Citect 7.20 the computer began to show the first signs of end of life. They never considered...
Replies
0
Views
73
I have a running backup of Citect and plc and I want to make a spare PC station so I have installed the win XP and somatic net v6.0 and import the...
Replies
3
Views
121
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
286
Looking for some help with the connection issue between Citect 2018 and Top Server v6 for Opto22. I’m setting all this up to communicate with some...
Replies
0
Views
118
Back
Top Bottom