Question MSChart: populate rowlabels and data from a dataset

Tinkerbell

Member
Joined
Sep 9, 2009
Messages
14
Programming Experience
1-3
Hello

I have a datagrid on my form which displays a data table from a DataSet (extracted from an Access DB). When the user selects an option from a combo box on the form I would like this same data to be displayed in an MSChart on the same page but I cant't work out the code to link the chart to the DataSet values.

I would like the Row Labels to be entries from a column in my dataset and the actual plotted data to be entries from another column, which I'll probably need some sort of loop for, but for now I just want to get one value working.

Here is part of the code:

VB.NET:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbDataAdapter
Imports System.Net.NetworkInformation

Public Class frmRealTime

Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\K0201227Project.accdb;Persist Security Info=False;"

Dim OleDBConn As New OleDbConnection()

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

OleDBConn.ConnectionString = ConnString

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


        Dim dsCB As New DataTable
        Dim SQLStrCB As String


        OleDBConn.ConnectionString = ConnString

        Select Case ComboBox1.Text

            Case "Cardiff"

                SQLStrCB = "SELECT * FROM tblRealTime WHERE SiteID = 'EM019'"
                Dim daCB As New OleDbDataAdapter(SQLStrCB, OleDBConn)
                daCB.Fill(dsCB)

                dgdRealTime.DataSource = dsCB

                Label1.Text = dgdRealTime.RowCount


                With chtRealTime '''the mschart'''
                   
                    .Row = 1
                    .RowLabel = '''''Want this to display an entry from the dataset''''
                    .Data = '''''Want this to display an entry from the dataset'''''

                End With

		.......................................

	End Select
End Sub
End Class


Thanks
Amy
 
Back
Top