AdvancedHMI Software

General Category => Support Questions => Topic started by: oqapsking on April 30, 2017, 12:26:07 AM

Title: chart and database
Post 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

Title: Re: chart and database
Post by: Godra on April 30, 2017, 12:51:06 AM
This is probably the topic with video you've been looking for:

http://advancedhmi.com/forum/index.php?PHPSESSID=5e98f7ea80c666b83e121d6db1c1ee92&topic=1341.0
Title: Re: chart and database
Post by: oqapsking on April 30, 2017, 01:26:54 AM
yes it is but i didn`t see how he made the database file
Title: Re: chart and database
Post by: oqapsking on April 30, 2017, 01:29:17 AM
and the code he uses is not vb net

and i am a noop
Title: Re: chart and database
Post by: oqapsking on April 30, 2017, 06:00:13 AM
can any one help me ?

how to make a database and use it with ahmi ?

Title: Re: chart and database
Post by: Phrog30 on April 30, 2017, 09:03:23 AM
What database are you using? I can give you an example for MySQL if that will help.
Title: Re: chart and database
Post by: oqapsking on April 30, 2017, 02:27:28 PM
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

Title: Re: chart and database
Post by: Phrog30 on April 30, 2017, 05:21:50 PM
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?
Title: Re: chart and database
Post by: oqapsking on April 30, 2017, 06:14:52 PM
the plc is a live feed

i didn`t decide how many samples to store each day

Title: Re: chart and database
Post by: Phrog30 on May 01, 2017, 09:47:23 PM
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.
Code: [Select]
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:
Code: [Select]
Imports MySql.Data.MySqlClientAlso, a reference to MySQL.Data.  Like I mentioned, Google has tons on this.

James

Title: Re: chart and database
Post by: oqapsking on May 02, 2017, 04:25:47 AM
thanks i will try it