Page 1 of 1

CheckDataSource doesn't update chart

Posted: Wed Nov 28, 2007 12:34 pm
by 9534375
Hi,
I am using Access database to store some values. In runtime I created two series with Teechart editor and connected Dataset with Access table.

I get values into Chart instantly.

Now I want to update values in a Chart. So I use VBScript to do it:

Code: Select all

Chart.Series(0).CheckDataSource
Chart.Series(1).CheckDataSource
Chart.Series(0).Name="test"
Chart is not updated with new values, but changes the name of the first series (the code should be correct, no error reported also.

I am using TeeChart v7 latest version.

Best regards.[/code]

Posted: Mon Dec 03, 2007 8:38 am
by Pep
Hi,

assigning the DataSource again should be the trick, like in the following example :

Code: Select all

Dim Data As New ADODB.Connection
Dim rst As New ADODB.Recordset

Private Sub Form_Load()
Data.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
               & App.Path & "\AccessTestDB.mdb;Persist Security Info=False"
rst.Open "select * from DataTwo", Data, 1, 1
With TChart1
    .Aspect.View3D = False
    .AddSeries scHorizBar
    .Series(0).DataSource = rst
    .Series(0).XValues.ValueSource = rst.Fields(1).Name
    .Series(0).YValues.ValueSource = rst.Fields(2).Name
    .Series(0).YValues.DateTime = True
End With
End Sub

Private Sub Timer1_Timer()
  UpdateRecordSet
  TChart1.Series(0).DataSource = rst
End Sub

Private Sub UpdateRecordSet()
  Data.Close
  Data.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
 & App.Path & "\AccessTestDB.mdb;Persist Security Info=False"
  rst.Open "select * from DataTwo", Data, 1, 1
End Sub