I know I'm pretty close to having this correct, but it's eating more time than I'd like to spend on it, so here I am, asking my trusty EE friends.
I have a simple CSV file which contains data such as:
This data represents Name, Total for May 2010, Total for April 2010 (the previous month)
I am trying to chart this using the new chart controls in VB2010, using a line. One line would show data for one month, and the other line would show the previous month.
Here is the code. I can get one month, or the other to show, but not both at the same time. I am sure it's something silly, but the day is almost over, and I can't wake up enough to figure it out.
In the lines where you see (myReader, 1, myReader, 2) etc, I was assuming that those numbers were representing the column number in the CSV file.
' Full path to the data source file
Dim file As String = "Top5.csv"
' Create a connection string.
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:/gatewaydata/" + ";Extended Properties=""Text;HDR=No;FMT=Delimited"""
Dim myConnection As New OleDbConnection(ConStr)
' Create a database command on the connection using query
Dim mySelectQuery As String = "Select * from " + file
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
' Open the connection and create the reader
Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' databind the reader to the chart using the DataBindXY method
Chart1.Series(0).Points.DataBindXY(myReader, 1, myReader, 2)
Chart1.Series(1).Points.DataBindXY(myReader, 1, myReader, 3)
' Close connection and data reader