0
我目前有一個有4個系列的圖表元素。我的問題是,雖然他們單獨工作,但如果我設置了多於1個系列,它將它們的數據設置爲最後一個DataSet
(因此係列具有與4相同的位置)。分離圖表系列
有人可以看看我破碎的代碼,讓我知道它出錯了嗎?也許有些關於整理它的指針......我以前從未使用任何形式的圖表。
Using con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test\Response.mdb;")
Dim MyQuery As String = "SELECT qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood, Count(qry_Response_By_Date_1.Mood) AS CountOfMood FROM qry_Response_By_Date_1 GROUP BY qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood HAVING (((qry_Response_By_Date_1.Mood)='Happy'));"
Using cmd = New OleDbCommand(MyQuery, con)
Dim MyData As New OleDbDataAdapter(MyQuery, con)
Dim MyDataSet As New DataSet
con.Open()
MyData.Fill(MyDataSet, "Table")
ChrtMoodChanges.DataSource = MyDataSet.Tables("Table")
Dim Series1 As Series = ChrtMoodChanges.Series("Series1")
Series1.Name = "Happy"
ChrtMoodChanges.Series(Series1.Name).XValueMember = "Actual_Date"
ChrtMoodChanges.Series(Series1.Name).YValueMembers = "CountOfMood"
End Using
Dim MyQuery2 As String = "SELECT qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood, Count(qry_Response_By_Date_1.Mood) AS CountOfMood FROM qry_Response_By_Date_1 GROUP BY qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood HAVING (((qry_Response_By_Date_1.Mood)='Neutral'));"
Using cmd = New OleDbCommand(MyQuery2, con)
Dim MyData2 As New OleDbDataAdapter(MyQuery2, con)
Dim MyDataSet2 As New DataSet
MyData2.Fill(MyDataSet2, "Table")
ChrtMoodChanges.DataSource = MyDataSet2.Tables("Table")
Dim Series2 As Series = ChrtMoodChanges.Series("Series2")
Series2.Name = "Neutral"
ChrtMoodChanges.Series(Series2.Name).XValueMember = "Actual_Date"
ChrtMoodChanges.Series(Series2.Name).YValueMembers = "CountOfMood"
End Using
Dim MyQuery3 As String = "SELECT qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood, Count(qry_Response_By_Date_1.Mood) AS CountOfMood FROM qry_Response_By_Date_1 GROUP BY qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood HAVING (((qry_Response_By_Date_1.Mood)='Sad'));"
Using cmd = New OleDbCommand(MyQuery3, con)
Dim MyData3 As New OleDbDataAdapter(MyQuery3, con)
Dim MyDataSet3 As New DataSet
MyData3.Fill(MyDataSet3, "Table")
ChrtMoodChanges.DataSource = MyDataSet3.Tables("Table")
Dim Series3 As Series = ChrtMoodChanges.Series("Series3")
Series3.Name = "Sad"
ChrtMoodChanges.Series(Series3.Name).XValueMember = "Actual_Date"
ChrtMoodChanges.Series(Series3.Name).YValueMembers = "CountOfMood"
End Using
Dim MyQuery4 As String = "SELECT qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood, Count(qry_Response_By_Date_1.Mood) AS CountOfMood FROM qry_Response_By_Date_1 GROUP BY qry_Response_By_Date_1.Actual_Date, qry_Response_By_Date_1.Mood HAVING (((qry_Response_By_Date_1.Mood)='Angry'));"
Using cmd = New OleDbCommand(MyQuery4, con)
Dim MyData4 As New OleDbDataAdapter(MyQuery4, con)
Dim MyDataSet4 As New DataSet
MyData4.Fill(MyDataSet4, "Table")
ChrtMoodChanges.DataSource = MyDataSet4.Tables("Table")
Dim Series4 As Series = ChrtMoodChanges.Series("Series4")
Series4.Name = "Angry"
ChrtMoodChanges.Series(Series4.Name).XValueMember = "Actual_Date"
ChrtMoodChanges.Series(Series4.Name).YValueMembers = "CountOfMood"
End Using
End Using
P.S. SQL爲每個返回正確的數據...它只是讓它將正確的數據存儲在圖表中是我的問題。