AdvancedHMI Software
General Category => Support Questions => Topic started by: MEDALI1TN on June 10, 2018, 04:39:19 AM
-
Hello.
i'm new with AdvancedHMI. (i use the version 35)
i'm using an OPC server (KEPServerEx V4.5) in order to connect to PLC siemens s7 300. : connection ok.
the configuration of OpcDaCom1 inside AdvancedHMI : ok.
i use the AnalogValueDisplay to read a word value from the OPC : ok. (without code, just i put the correct TAG in the PLCaddressvalue).
the problem is :
i have one Foat Array tab [76 elements], and i need to read each value separate.
the best solution for me is to write them in a database.
thank you.
-
I started the experiment with COPC32, but due to the license problem, I switched to advancedhmi.
below the code I used to read some values (with COPC32) :
Private Sub Label2_Click(sender As System.Object, e As System.EventArgs) Handles Label2.Click
Dim words(76) As Single
words = Axcopc1.GetVl(1)
Dim A As Single = words(0)
Dim B As Single = words(1)
Dim C As Single = words(3)
Dim D As Single = ( A * B * C)
Label2.Text = D.ToString()
End Sub
-
is it correct ?
Private Sub BasicLabel1_Click(sender As System.Object, e As System.EventArgs) Handles BasicLabel1.Click
Dim words(76) As Single
words = OpcDaCom1.Read("words(0)", 76)
Dim A As Single = words(0)
Dim B As Single = words(1)
Dim C As Single = words(3)
Dim D As Single = (A * B * C)
BasicLabel1.Text = D
End Sub
-
if it is possible to display the values in a table like in the attached pic
also all values must be stored in a database SQL Server
-
screenshot of the OPC server and OPC client
-
This would be more correct. There is not need to define the array size because the driver creates a new array of the correct size.
Private Sub BasicLabel1_Click(sender As System.Object, e As System.EventArgs) Handles BasicLabel1.Click
Dim words() As String
words = OpcDaCom1.Read("words(0)", 76) '* The address is dependent on the OPC Server
Dim A As Single = CSNG(words(0))
Dim B As Single = CSNG(words(1))
Dim C As Single = CSNG(words(3))
Dim D As Single = (A * B * C)
BasicLabel1.Text = D
End Sub
-
thnx for your reply.
attached the error message after the test.
-
I don't think you can read a udt array like that.
-
is there another way to read the data (Array tab [x elements]) and store it in a database (or excel) ?
I need this architecture :
PLC (siemens s7 300) -> OPC (KEPServerEx V4.5) -> AdvancedHMI (i use v 35) -> Form and stored in database or in excel
Thanks for your help.
-
I thought you were using the clx driver, so not sure if what I said is correct.
-
You could experiment with the attached modified version of OpcDaCom.vb file.
Download the file and then just right-click the AdvancedHMIDrivers project and select Add/Existing Item, browse to and select this downloaded file and replace the current file.
Currently, you have to address the whole array, without "( 0 )" or "[ 0 ]" at the end and without specifying 76.
Here is the example (use standard Label instead of BasicLabel):
Using Read function:
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
Dim words() As String
words = OpcDaCom1.Read("Data Type Examples.16 Bit Device.K Registers.FloatArray", 1)
Dim A As Single = CSng(words(0))
Dim B As Single = CSng(words(1))
Dim C As Single = CSng(words(3))
Dim D As Single = (A * B * C)
Label3.Text = D
End Sub
Using Subscribe function which will automatically update the values whenever they change:
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OpcDaCom1.Subscribe("Data Type Examples.16 Bit Device.K Registers.FloatArray", 1, 0, AddressOf SubscribedDataChanged)
End Sub
Private Sub SubscribedDataChanged(sender As Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If e.ErrorId = 0 Then
If e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.FloatArray" Then
Dim D As Single = (e.Values(0) * e.Values(1) * e.Values(3))
Label3.Text = D
End If
End If
End Sub
The driver's DataReceived event should work for all values that are returned, so you might consider that as an option as well.
Writing to array doesn't seem to be currently working.
-
thank you for your help.
after the integration of the new OpcDaCom.vb , I got two errors.
-
Just change the word Integer to String (just before the word "Implements" on Line 400).
The Return line within that function should also be corrected to: Return CStr(Write(startAddress, 1, temp))
Or maybe consider downloading and using the latest beta version of AHMI.
-
thank you
I followed your instruction, the problem is solved, but I have another error message.
(I inform you that I have not been able to display values).
i use the latest beta version of AHMI "AdvancedHMIv399x "
-
What is the Tag for your array and do you know if there are any values currently in the array?
-
You need to know your Tags and the last post in this topic explains how to achieve that:
https://www.advancedhmi.com/forum/index.php?topic=648.msg2968#msg2968
-
I just checked the screenshot of the OPC server and OPC client which you posted previously.
Your Tag shows as KWh_Tg_akt (but it might be longer as the screenshot only shows a part of it, like .EM.KWh_Tg_akt).
This is the tag that you need to use instead of: Data Type Examples.16 Bit Device.K Registers.FloatArray
So the previous code examples should be modified to look similar to this:
Using Read function:
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
Dim words() As String
words = OpcDaCom1.Read("KWh_Tg_akt", 1)
Dim A As Single = CSng(words(0))
Dim B As Single = CSng(words(1))
Dim C As Single = CSng(words(3))
Dim D As Single = (A * B * C)
Label3.Text = D
End Sub
Using Subscribe function which will automatically update the values whenever they change:
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OpcDaCom1.Subscribe("KWh_Tg_akt", 1, 0, AddressOf SubscribedDataChanged)
End Sub
Private Sub SubscribedDataChanged(sender As Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If e.ErrorId = 0 Then
If e.PlcAddress = "KWh_Tg_akt" Then
Dim D As Single = (e.Values(0) * e.Values(1) * e.Values(3))
Label3.Text = D
End If
End If
End Sub
-
thanks a lot for your help
Finally, I succeeded to display all the information that I need.
another thing please :
I need to store all those informations in a database every 5 sec for example.
-
I cannot really help you with that part but some other forum members might be able to help.
You will first need to decide what you would like to use to store all the data (csv file or excel file or some variant of SQL database ...or...).
Here is a few topics in this forum with some examples:
https://www.advancedhmi.com/forum/index.php?topic=1750.0
https://www.advancedhmi.com/forum/index.php?PHPSESSID=5e98f7ea80c666b83e121d6db1c1ee92&topic=1341.0
https://www.advancedhmi.com/forum/index.php?topic=1378.0
You should consider using the Subscribe function example since it will be recording the data only when it changes (adding the timestamp along with the data values would probably be helpful).
Using BasicDataLogger2 component would be one of the options.
-
There are a ton of examples on the web about database stuff. I use sqllite and it works well. I've posted a few apps that have it built in. Feel free to look at them.
-
I'm sorry to say that until now, I have not been able to write the data already displayed in a database ...
thanks for all who helped me.
-
is there a way to transfer all the data to excel file in real time?
PLC -> OPC -> AdvancedHMI application -> excel
if yes, how much recording data can I transfer ?
-
What is your problem in writing to a database? Using Excel is very simple, Archie has posted sample applications, but using Excel is clunky at best. Using a database is a lot better.
-
On the AdvancedHMI YouTube channel is a video that shows how to log data to a database. It uses Data Sources which is a tool within Visual Studio that makes it fairly easy. See this thread for a link to the video:
https://www.advancedhmi.com/forum/index.php?topic=1341.msg7123#msg7123
At about 10:00 into the video is where is shows the database information.
-
thank you friends.
I followed your instructions
I encountered the following error.
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Using t As New dbalfaDataSet.DataSamplesDataTable
t.AddDataSamplesRow(t.NewRow)
t(0).value = e.Values(0)
Using ta As New dbalfaDataSetTableAdapters.DataSamplesTableAdapter
ta.update(t)
End Using
End Using
End Sub
-
attached the options displayed after choosing dataset and SetTableAdapters
-
It looks like you named your data table EM, not DataSample.
-
Thank you Archie
The code seems works without error.
I'm sorry because I'm a beginner and I hope it does not bother you.
I need to know haw can i choose a variable from the array to write it in the database ?
I need to know how to link a variable from array (opc) to the database.
My code :
Read a variable from OPC I1 :
Private Sub Label2_Click(sender As System.Object, e As System.EventArgs)
Dim words() As String
words = OpcDaCom1.Read("TEST.EM.KWh_Tg_akt", 1)
Dim I1 As Single = CSng(words(1))
Label2.Text = I1
End Sub
instant update of the variable I1:
Private Sub SubscribedDataChanged(sender As Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If e.ErrorId = 0 Then
If e.PlcAddress = "TEST.EM.KWh_Tg_akt" Then
Dim I1 As Single = (e.Values(1))
Label2.Text = I1
End If
End If
End Sub
The Database :
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Using t As New dbalfaDataSet.EMDataTable
t.AddEMRow(t.NewRow)
t(0).TEST = e.Values(0)
Using ta As New dbalfaDataSetTableAdapters.EMTableAdapter
ta.Update(t)
End Using
End Using
End Sub
-
I tried to connect to a MySql database and I succeeded, but the problem is that I get the first 100 values only.
and I have not found a solution until now.
Public Class MainForm
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
.
.
.
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString =
"server=localhost;userid=root;password=;database=technique"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "insert into technique.DATA (id,value) values ('" & 0 & "' , '" & BasicLabel4.Value & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
Catch ex As Exception
MysqlConn.Close()
End Try
the solution that you proposed is better and very useful.
because you can connect directly and automatically to a database SQLSERVER (generate all the fields automatically).
can you correct this code for me please :
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Using t As New techniqueDataSet.DATADataTable
t.AddDATARow(t.NewRow)
t(0).value = e.Values(0)
Using ta As New techniqueDataSetTableAdapters.DATATableAdapter
ta.Update(t)
End Using
End Using
End Sub
-
Have you tried using Fill instead of Update ( ta.Fill(t) )?
-
If your code works once only then try moving it to a sub like this:
Private Sub BasicLabel4_ValueChanged(sender As Object, e As EventArgs) Handles BasicLabel4.ValueChanged
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString =
"server=localhost;userid=root;password=;database=technique"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "insert into technique.DATA (id,value) values ('" & 0 & "' , '" & BasicLabel4.Value & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
Catch ex As Exception
MysqlConn.Close()
End Try
End Sub
-
thank you friends
The connection to mysql is not stable and sometimes it does not work without any warning.
I need to store the data in a SQL SERVER database via DataSubscriber.
@Godra, i try to use ta.Fill(t)
the error message is gone but the function did not work
no error message and no record in the database.
-
In have used MySQL a bunch, it's not unstable in the least. You are doing something wrong. One post you stated you get only 100 values but you showed insert statement, so how are you seeing the data, within MySQL?
-
data storage is working properly, up to line number 100 (id = 100 "AUTO_INCREMENT")
the application stops working (the main form application) => become unresponsive
and no new registration in the database
every time in line number 100
-
i use the value as 0 in order to test the program
but the same problem
-
I think you are doing the database stuff completely backwards. Forget Visual Studio. Matter of fact, close the application. You need to learn the DB side first, regardless if you use SQL, MySQL, etc. Since it looks like you have gotten farther in MySQL, I would use that. You can run queries straight from the workbench. So, run your own insert statements, learn how to do select statements, etc. Then once you have the DB working, you simply copy the queries and paste in VS. Your form being unresponsive most likely has nothing to do with MySQL, rather your code in VS. Running a transaction with only 100 rows should take almost no time at all. You shouldn't notice the UI lock up at all. For giggles, run a select * in workbench, it will tell you how long it takes. It's probably so fast it will say 0.
-
I tried sql alone: it works
and the application without queries works properly and especially without blocking (never)
only if I use the database, and exactly when the ID reaches line number 100 !!!
-
I put all the code in comment and I activated only the request.
the same thing, when the ID reaches line number 100 the application crashes.
I think there is a limit in the base (limit in the number of lines).
because if I restart the application without initializing the counter, it will appear a line that makes the separation between the value 100 and 101.
-
I don't know if this might work but it doesn't hurt to try:
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Dim conString As String = "server=localhost;userid=root;password=;database=technique"
Using con As New MySqlConnection(conString)
Using cmd As New MySqlCommand("insert into technique.DATA (id,value) values ('" & 0 & "' , '" & e.Values(0) & "')", con)
cmd.CommandType = CommandType.Text
Using sda As New MySqlDataAdapter(cmd)
Using dt As New DataTable()
sda.Fill(dt)
End Using
End Using
End Using
End Using
End Sub
The code was adopted from here:
https://www.aspsnippets.com/Articles/Fill-Populate-DataTable-using-MySqlDataAdapter-in-C-and-VBNet.aspx
If it might need to use your settings then it would look like this:
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Dim conString As String = "server=localhost;userid=root;password=;database=technique"
Using con As New MySqlConnection(conString)
Using cmd As New MySqlCommand("insert into technique.DATA (id,value) values ('" & 0 & "' , '" & e.Values(0) & "')", con)
cmd.CommandType = CommandType.Text
Using sda As New techniqueDataSetTableAdapters.DATATableAdapter(cmd)
Using dt As New techniqueDataSet.DATADataTable()
sda.Fill(dt)
End Using
End Using
End Using
End Using
End Sub
-
Thank you friend.
Unfortunately it did not work :(
I think that with "DataSubscriber1_DataReturned" he wants to connect to SQLSERVER and not MySQL.
the program looking for user 'sa'
-
Are you trying to insert at specific IDs? I would create the table with auto increment and unique IDs. Let the database do all of the work. If you are only wanting 100 rows and those get updated, then I probably wouldn't even use a database.
-
i use already the auto increment id.
I already need a few thousand lines a day
I want to read the current absorbed by the machines instantly
-
I have not been able to fully keep up with this topic and only have a few minutes to respond, so I want to quickly clarify a few things about data sources. The Data Source is a Visual Studio tool that creates classes that maps to tables, View, and Procedures of a database. When you create a Data Source, you tell it what type of data base and how to connect to it. The Table Adapters contain the mechanisms to move data in and out of a data base. The Fill method is a read command while an Update is a write command. The Data Tables are the objects that hold the actual data in memory from the database. When you call Fill, it reads from the database and transfers the values to a Data Table. When you call Update, it transfers the changes made to the Data Table back to the data base.
Once you define a Data Source, it is dedicated to the database you defines. For example, if you create a data source for a SQL Server, it will not communicate to MySQL without major changes. If you want to change databases, you are better off to create a new Data Source.
The Data Source is just a tool to reduce the amount of code necessary for database interaction. They are not necessary to use. You can use raw ADO.NET and manually write the code.
-
i use already the auto increment id.
I already need a few thousand lines a day
I want to read the current absorbed by the machines instantly
But, it looks like your insert statement is setting an ID. You don't set the id, you let the database do that.
-
I did more than 1000 test but without success...
I thank you all friends for your help..
-
I was just trying MySQL, and here is what worked for me without creating a Data Source:
Private Sub DataSubscriber1_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataReturned
Dim conString As String = "server=presario-c700;userid=dell;password=;database=test"
Using con As New MySqlConnection(conString)
Using cmd As New MySqlCommand
With cmd
.Connection = con
.CommandText = "INSERT INTO test.datatable (value) VALUES (@value)"
.CommandType = CommandType.Text
.Parameters.AddWithValue("@value", e.Values(0))
End With
Try
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message + System.Environment.NewLine, "MySQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Using
End Using
End Sub
This is the configuration:
Database = test
Database Table = datatable
Database Table Fields = id and value
The code above was adopted from Phrog30's other project and it did insert more than a 100 values into "value" field while "id" field was auto incremented.
If you want to try it then just correct parts that apply to your setup (like server, userid, password, database, datatable).
Attached is the picture of MySQL.
-
Here is a couple more screenshots of MySQL and this time with timestamp column, automatically populated by MySQL upon insertion of new values.
-
I think database stuff is fun. I wish I knew more about, I wouldn't mind doing that stuff full time.
-
thank you friends
It works very well
thannnnnnnnnnnnnnnnnnnnnnnnnkkkkkkkkkkkkk
Just i want to add to the value in the database some words like Kw or Volt
exmp: 100 KVA
another thing please, how I can program the writing in the database
for example I want to write the information every 5 min
all my thanks to Godra, Archie, Phrog30 .... and all the team
-
You have a few options,
1. Add another column and insert units.
2. Change the current column to varchar and before inserting the data, concatenate the value and unit into one string.
I'm going to say best practice is add another column so any queries will be easier to do. Just my opinion though.
The way godra showed, you can add more parameters.
-
For timed writing you could add a timer to the form, enable it and set its interval to 300000 (this is in milliseconds which equals 5 minutes).
Then double click the timer to take you back to the code, which will be its tick event, and here is where you would setup the reading of the values (your writing to the database should then be done in the DataReceived event of the opc driver).
Another possible way could be to use a timer in the PLC and set certain bit to true when 5 minutes is up.
Then you can use the DataSubscriber to observe this bit and whenever it goes true then write to the database (you would also reset the bit which should restart the timer).
-
Here is another possible way, a simple example for timed writing to MySQL database, so make sure to check the attached pictures as well:
Only standard labels are used in this example.
A DataSubscriber2 component is added to the form and it is set to observe 4 x Boolean plus 1 x FloatArray PLC addresses.
It is set to update form labels whenever data changes.
A Timer is also added to the form, set to enabled and with an interval of 10000 (which is 10 seconds).
Every 10 seconds the timer is collecting values currently displayed in the labels and writing them to the database.
Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged
If e.ErrorId = 0 Then
If e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.Boolean1" Then
Label6.Text = e.Values(0)
ElseIf e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.Boolean2" Then
Label7.Text = e.Values(0)
ElseIf e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.Boolean3" Then
Label8.Text = e.Values(0)
ElseIf e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.Boolean4" Then
Label9.Text = e.Values(0)
ElseIf e.PlcAddress = "Data Type Examples.16 Bit Device.K Registers.FloatArray" Then
Label14.Text = e.Values(0)
Label15.Text = e.Values(1)
Label16.Text = e.Values(2)
Label17.Text = e.Values(3)
End If
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim conString As String = "server=presario-c700;userid=dell;password=;database=test"
Using con As New MySqlConnection(conString)
Using cmd As New MySqlCommand
With cmd
.Connection = con
.CommandText = "INSERT INTO test.datatable (Bool1, Bool2, Bool3, Bool4, FloatArr0, FloatArr1, FloatArr2, FloatArr3) VALUES (@val1, @val2, @val3, @val4, @val5, @val6, @val7, @val8)"
.CommandType = CommandType.Text
.Parameters.AddWithValue("@val1", Convert.ToInt32(CBool(Label6.Text)))
.Parameters.AddWithValue("@val2", Convert.ToInt32(CBool(Label7.Text)))
.Parameters.AddWithValue("@val3", Convert.ToInt32(CBool(Label8.Text)))
.Parameters.AddWithValue("@val4", Convert.ToInt32(CBool(Label9.Text)))
.Parameters.AddWithValue("@val5", Convert.ToSingle(Label14.Text))
.Parameters.AddWithValue("@val6", Convert.ToSingle(Label15.Text))
.Parameters.AddWithValue("@val7", Convert.ToSingle(Label16.Text))
.Parameters.AddWithValue("@val8", Convert.ToSingle(Label17.Text))
End With
Try
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message + System.Environment.NewLine, "MySQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Using
End Using
End Sub
-
Just for anybody who might be interested, here is a few more screenshots of how to administer MySQL server via web.
The program is called phpMyAdmin and could be installed by using XAMPP installer:
https://www.apachefriends.org/index.html
For my test, during the setup I only selected Apache, PHP and phpMyAdmin (MySQL server was already installed on another computer).
Small modifications are required to be done to the config.inc.php file, related to the IP address/user/password for MySQL server.
This file is accessed by clicking the "Config" button in the XAMPP Control Panel.
The browser and the dashboard are started by clicking the "Admin" button (you have to start the Apache server prior to this).
phpMyAdmin is started from the dashboard.
-
Thank you friends
I became an expert on reading variables and saving them in the database
And that's thanks to you.
when programming my first application I encountered some problems and all I need to insert different parameters of several tabs (which I already achieve by advanced HMI) but with conditions.
for example, inserting a variable x from a table TAB1 into a table TAB2 only if the variable Y of TAB2 equals 1.
-
Google is your friend, you just have to type:
https://stackoverflow.com/questions/4241621/mysql-insert-into-table-data-from-another-table (https://stackoverflow.com/questions/4241621/mysql-insert-into-table-data-from-another-table)
If this isn't quite what you are looking for, there are more where that came from, just look harder. There are other sites that can help better on database stuff than here, stack overflow is one...
-
Hi Ghodra/Phrog 30,
I am using Microsoft SQL data base(File) with table dbo.DataFile and trying to update Seq,Serial columns, with PLC addresses: Record_Seq and Record_Serial using basicdatalogger 2 when event changes (Number_Validated bit).
Using following code:
Private Value1, Value2 As String
Private Sub BasicDataLogger21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles BasicDataLogger21.DataChanged
If e.PlcAddress = "Number_Validated" Then
BasicLabel1.Text = e.Values(0)
BasicLabel2.Text = e.Values(1)
End If
Dim con As New SqlClient.SqlConnection
Dim cmd As New SqlClient.SqlCommand
Try
con.ConnectionString = "Data Source=xxx.10.14.xxx;Initial Catalog=info;UID=sa;PWD=user"
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Test(value1,value2) VALUES(@Value1,@Value2)"
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
Finally
con.Close()
End Try
I am not pretty much sure with the code and very new to VB. Can you please help me out how to record Seq,Serial data in database table when Number_Validated bit changes it state.
Thanks
-
You should be using the latest v3.99y Beta version of AHMI, since it has the BasicDataLogger2 component with the latest updates.
Or check this post here: https://www.advancedhmi.com/forum/index.php?topic=2027.msg11388#msg11388
Then read all the posts in this topic, starting with reply #45 ... it shows what you need to know in general.
I am not familiar with SQL but will suggest that you pay attention to format used in code for MySQL:
The code in replies #45 and #51, when generalized, shows as this:
INSERT INTO databaseName.datatableName (column1name, column2name) VALUES (@Value1, @Value2)
Your database seems to be named "File" and the datatable is "dbo.DataFile" with columns "Seq" and "Serial", so the code in your case should be:
INSERT INTO File.dbo.DataFile (Seq, Serial) VALUES (@Value1, @Value2)
and then specify the values with:
.Parameters.AddWithValue("@Value1", e.Values(0))
.Parameters.AddWithValue("@Value2", e.Values(1))
And also make sure to compare the format of the ConnectionString used in MySQL to the one you posted.
This is all suggested only as a general guidance.
You might try using the code posted in replies as it is, just change MySQL to SQL related entries and remove all unnecessary items.
-
Thanks Godra, I got this working
-
If you would care to share your working code/solution, that might eventually help someone else.
-
Sorry for late reply.
I did the same thing what Archie asked to do in https://www.advancedhmi.com/forum/index.php?topic=1864.msg10345#msg10345 reply 1. Code will be the same.
Thanks