DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Help with MsChart and Access Database

  1. #1
    Join Date
    Mar 2005
    Posts
    49

    Help with MsChart and Access Database

    Hi Guys,

    I am trying to plot a graph from data present in the Access database.

    I created a database called "RotorData.mdb" and then created a table called "Timings". In this table there are three fields "SubjectID", "Time1"
    and "PercentageTime". I want to plot a graph of Time1 vs PercentageTime.
    I want to use MsChart control for this purpose. The code I found in VB help
    is not generating any plot. Please help me.


    Code:
    ==========================
    Option Explicit
    ' Be sure to set a reference to the Microsoft ActiveX Data
    ' Objects 2.0 Library.
    Private rsProducts As New ADODB.Recordset
    Private cn As New ADODB.Connection

    Private Sub Command2_Click()
    Dim strQuery As String ' SQL query string.
    ' First change the path to a valid path for your machine.
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=C:\VB-Examples\Rotor\RotorData.mdb" ' <-Change this path.
    ' Open the connection.
    cn.Open

    ' Create a query that retrieves only four fields.
    strQuery = "SELECT Time1, PercentageTime FROM Timings WHERE
    SubjectID =
    1001"
    ' Open the recordset.
    rsProducts.Open strQuery, cn, adOpenKeyset

    ' Set the DataSource to the recordset.
    With MSChart1
    .chartType = VtChChartType2dLine
    .ShowLegend = True
    Set .DataSource = rsProducts
    End With
    End Sub

    ====================================

    Thanks

  2. #2
    Join Date
    Jan 2004
    Location
    Alexandria, VA
    Posts
    392
    The datasource link may not work. Also, I think you have to tell it to plot the data. http://msdn.microsoft.com/library/de...hartobject.asp
    Bob Rouse
    Dimension Data

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center