title: How to update a Chart
body: <p>I've just finished developing a piece of code where I am able to create a <code>Chart</code> and query from my database. Here I insert values from the database and it will show to the user.</p>
  
  <p>I will post here the code that I've done to create a chart:</p>
  
  <pre><code>Public Sub BuildChart()
      Try
          SQLCon = New SqlConnection
          SQLCon.ConnectionString = "........."
          Dim sqlStatis As String = "SELECT Top 5 Filename, Filesize FROM infofile"
          Dim Chart1 As New Chart()
          Dim da As New SqlDataAdapter(sqlStatis, SQLCon)
          Dim ds As New DataSet()
          da.Fill(ds, "infofile")
  
          Dim ChartArea1 As ChartArea = New ChartArea()
          Dim Legend1 As Legend = New Legend()
          Dim Series1 As Series = New Series()
          Me.Controls.Add(Chart1)
  
          ChartArea1.Name = "ChartArea1"
          Chart1.ChartAreas.Add(ChartArea1)
          Legend1.Name = "Legend1"
          Chart1.Legends.Add(Legend1)
          Chart1.Location = New System.Drawing.Point(12, 12)
          Chart1.Name = "Chart1"
          Series1.ChartArea = "ChartArea1"
          Series1.Legend = "Legend1"
          Series1.Name = "Tamanho do ficheiro"
          Chart1.Series.Add(Series1)
          Chart1.Size = New System.Drawing.Size(600, 300)
          Chart1.TabIndex = 0
          Chart1.Text = "Chart1"
  
          Chart1.Series("Tamanho do ficheiro").XValueMember = "Filename"
          Chart1.Series("Tamanho do ficheiro").YValueMembers = "Filesize"
  
          Chart1.DataSource = ds.Tables("infofile")
      Catch ex As Exception
          MessageBox.Show(ex.ToString())
      Finally
          SQLCon.Dispose()
      End Try
  End Sub
  </code></pre>
  
  <p>As you can see I've created a method which will be called in the form and the info will be shown there. Outside of everything I declared a variable <code>Dim Chart1 As New Chart()</code>. Now I want to create a method which allows me with a timer to update automatically the chart. So I should create another method called <code>UpdateChart</code> where I could insert there this:</p>
  
  <pre><code>Timer1.Interval = 3000
  Timer1.Start()
  </code></pre>
  
  <p>But now I have no idea what should I use to update it every 3 secs or 3000 milliseconds.</p>