AdvancedHMI Software
General Category => Support Questions => Topic started by: oqapsking on April 30, 2017, 12:26:07 AM
-
hello
there was a video about making a chart and connect it to database and i cant find it
what i need to do
say i have a basiclabel reads some register
and i want to store the values on database file and display them in chart
in the chart i can choose the from date to date and time to time
by the way i dont have experience in database usage
with thanks
-
This is probably the topic with video you've been looking for:
http://advancedhmi.com/forum/index.php?PHPSESSID=5e98f7ea80c666b83e121d6db1c1ee92&topic=1341.0
-
yes it is but i didn`t see how he made the database file
-
and the code he uses is not vb net
and i am a noop
-
can any one help me ?
how to make a database and use it with ahmi ?
-
What database are you using? I can give you an example for MySQL if that will help.
-
I have none
As i said i am a noop
What i am trying to do is this
My project reads data from multi plcs
So am gonna make a database that stores the following
Name of the plc , temp1 , temp 2 ... And the date
Then am gonna show them in the chart
I show the multi graphs say gragh 1 for plc 1 temp 1 i chose from day 1 to day 31 and shows the temp1 on it
-
I recommend MySQL community, it's free. It is very simple to use. There are a lot of tutorials on the web that will walk you through every step. Search for MySQL vb.net.
How often are you reading from the PLC to the DB? How long are you wanting to keep the data?
-
the plc is a live feed
i didn`t decide how many samples to store each day
-
Here is some very basic code that you can use to get data from DB to your chart. This for MySQL and it assumes you know some basics in .NET.
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString =
"server=localhost;userid=root;password=root;database=database"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "select * from database.data"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
While READER.Read
Chart1.Series(0).Points.AddXY(READER.GetString("name"), READER.GetInt32("age")) 'this is just an example...
End While
MysqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
You will need:Imports MySql.Data.MySqlClient
Also, a reference to MySQL.Data. Like I mentioned, Google has tons on this.
James
-
thanks i will try it