Page 1 of 1

update chart from a database

Posted: Wed Dec 14, 2005 7:55 am
by 9525868
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

Posted: Thu Dec 15, 2005 4:22 am
by 9525868
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

Posted: Mon Dec 19, 2005 10:09 am
by Pep
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

Posted: Mon Dec 19, 2005 11:29 am
by 9525868
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

Posted: Tue Dec 27, 2005 10:35 am
by Pep
Hi Samir,

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