Hello everyone....

I would like to display data from my database in a chart.

I don't seem to be able to figure out how to get it working though!

I have tried the following code to bind the chart to my dataset but no joy!

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ../SR.mdb"
        sql = "Select [ProdCell],[Competence] from Skills where EmpNo = " & UEmpNo & " Order By [ProdCell]"
        DSeS = ESDatCon.SelectData(sql, con)

        Chart1.Series(0).Points.DataBindXY(DSeS.Tables(0).Rows(0)("ProdCell"), DSeS.Tables(0).Rows(0)("Competence"))
        Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut

Am I working along the right lines or am I going about it completely wrong?

Thanks for any help/advice!


5 Years
Discussion Span
Last Post by Goomba79

You aren't using the dataSource method to match your dataset to the chart for a start. Have a look at the chart doc on MSDN, that will help you a lot.



what i want to do is display the pie chart as such

say i have 100 records each has a competence of 1 - 4

the pie chart will have 4 segments and be devided in to the segments by how many records have a competence of 1,2,3,4

i have used this to display data in a chart

sql = "Select [ProdCell],[Competence] from Skills where EmpNo = " & UEmpNo & " Order By [ProdCell]"

DT = ESDatCon.SelectTable(sql, con)

Chart1.Series("Series1").XValueMember = "ProdCell"
Chart1.Series("Series1").YValueMembers = "Competence"
Chart1.DataSource = DT

but i cant work out how to count how many records have a competence of 1, how many have a competence of 2 etc and display the 4 results in a pie chart

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.