update chart from a database

TeeChart for ActiveX, COM and ASP
Post Reply
samir
Newbie
Newbie
Posts: 12
Joined: Fri Feb 04, 2005 5:00 am

update chart from a database

Post by samir » Wed Dec 14, 2005 7:55 am

Public i As Integer
Public CON As New Connection
Private Sub Command1_Click()
Set CON = New Connection
CON.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\" & "TimeStamp.mdb"
Dim rs As New Recordset
rs.Open "Select * from MilliSeconds", CON, adOpenKeyset, adLockOptimistic
rs.AddNew
rs![MilliSec] = Label2.Caption
rs.Update
rs.Close
End Sub

Private Sub Command2_Click()

With TChart1.Series(0)
' remove previous existing points from the Series
.Clear



' add new points to the Series...
' .Add 100, "Europe", vbRed
' .Add 300, "USA", vbBlue
' .Add 200, "Asia", vbGreen
' .Add 120, "Australia", vbYellow
End With
'End Sub
End Sub

Private Sub Command3_Click()
TChart1.Series(0).CheckDataSource

' add new points to the Series...
' .Add 100, "Europe", vbRed
' .Add 300, "USA", vbBlue
' .Add 200, "Asia", vbGreen
' .Add 120, "Australia", vbYellow
' End With
'End Sub
End Sub

Private Sub Form_Terminate()
'MsgBox "Thanks for using.", , "Thanks"
End Sub

Private Sub Timer1_Timer()
Timer1.Interval = 1
Label2.Caption = Format(Time, "hh:mm:ss")
'+ ":" + Label1.Caption
'''Label1.Caption = Val(Label1.Caption) + 1
'''If Label1.Caption = 100 Then
'''Label1.Caption = 1
'End If
Call run1
Call run
Set CON = New Connection
CON.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\" & "TimeStamp.mdb"
Dim rs As New Recordset
rs.Open "Select * from MilliSeconds", CON, adOpenKeyset, adLockOptimistic
rs.AddNew
rs![MilliSec] = Label2.Caption

rs.Fields(1) = sec.Caption
rs.Update
rs.Close
End Sub
Public Sub run1()

If i = 10000 Then
i = 0
Else
i = i + Timer1.Interval
End If



End Sub

Public Sub run()
sec.Caption = i
End Sub


Here is the code I am using. I want to update the teechart as the values are being populated in the mdb file. So that the graph is running realtime but with values from the database. Please help have uploaded the project in the public attchments folder..


Samir

samir
Newbie
Newbie
Posts: 12
Joined: Fri Feb 04, 2005 5:00 am

Post by samir » Thu Dec 15, 2005 4:22 am

Here is the code I am using. I want to update the teechart as the values are being populated in the mdb file. So that the graph is running realtime but with values from the database. Please help have uploaded the project in the public attchments folder.. please help urgently please

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 19, 2005 10:09 am

Hi Samir,

you will have to use similar code as in the following one :

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

samir
Newbie
Newbie
Posts: 12
Joined: Fri Feb 04, 2005 5:00 am

Post by samir » Mon Dec 19, 2005 11:29 am

Hi need to do this fast line and the x-axis is date time and the yaxis is the values. Have attached my programme in the steems attachments newsgroup please see

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Dec 27, 2005 10:35 am

Hi Samir,

I've modified your example and post it again into the attachments newsgroup.

Post Reply