I have never created a chart before and don't understand how to do it. I want to create a bar graph that shows the competitor name and how many wins each competitor has. Access.DBDT is my data source.
I tried this but get the following error on "Chart2.DataSource = Access.DBDT.TableName("CompetitionDate")"
"An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll Additional information: Conversion from string "CompetitionDate" to type 'Integer' is not valid."
Here is the code...
Private Sub Charts_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Access.ExecQuery("SELECT CompetitionDate.FirstName, CompetitionDate.LastName, CompetitionDate.Wins FROM CompetitionDate ORDER BY Wins")
Dim ChartArea2 As ChartArea = New ChartArea()
Dim Legend2 As Legend = New Legend()
Dim Wins2 As Series = New Series()
Dim Chart2 = New Chart()
Me.Controls.Add(Chart2)
ChartArea2.Name = "ChartArea2"
Chart1.ChartAreas.Add(ChartArea2)
Legend2.Name = "Legend2"
Chart2.Legends.Add(Legend2)
Chart2.Location = New System.Drawing.Point(13, 13)
Chart2.Name = "Chart2"
Wins2.ChartArea = "ChartArea2"
Wins2.Legend = "Legend2"
Wins2.Name = "Wins"
Chart2.Series.Add(Wins2)
Chart2.Size = New System.Drawing.Size(800, 400)
Chart2.TabIndex = 0
Chart2.Text = "Total Wins"
Chart2.Series("Wins").XValueMember = "FirstName"
Chart2.Series("Wins").YValueMembers = "Wins"
Chart2.DataSource = Access.DBDT.TableName("CompetitionDate")
End Sub