Author Topic: chart and database  (Read 2342 times)

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
chart and database
« 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


Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: chart and database
« Reply #1 on: April 30, 2017, 12:51:06 AM »

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #2 on: April 30, 2017, 01:26:54 AM »
yes it is but i didn`t see how he made the database file

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #3 on: April 30, 2017, 01:29:17 AM »
and the code he uses is not vb net

and i am a noop

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #4 on: April 30, 2017, 06:00:13 AM »
can any one help me ?

how to make a database and use it with ahmi ?


Phrog30

  • Guest
Re: chart and database
« Reply #5 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.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #6 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


Phrog30

  • Guest
Re: chart and database
« Reply #7 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?

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #8 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


Phrog30

  • Guest
Re: chart and database
« Reply #9 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


oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: chart and database
« Reply #10 on: May 02, 2017, 04:25:47 AM »
thanks i will try it