addchartPrevious24() というサブがあります
このサブルーチンは、初期ロード時およびユーザーがリフレッシュを要求したときに呼び出されます。この潜水艦の仕事は、情報を照会するデータベースにアクセスすることです。データセットに入力します。次に、グラフとグラフ エリアを作成します。次に、データセットがチャートのデータソースとして設定されます。私の問題は、サブを再実行すると、データセットは更新されますが、新しいデータでチャートが更新されないことです。
Public Sub addchartPrevious24()
Dim Connection As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\manage.mdb;Jet OLEDB:Database Password=password")
Dim da1 As New OleDb.OleDbDataAdapter
Dim ds1 As New DataSet()
Dim Command As New OleDb.OleDbCommand
Connection.Open()
da1.SelectCommand = New OleDb.OleDbCommand("SELECT General_Counters_Table.product_id, Sum(General_Counters_Table.ulboardcyclecount) AS SumOfulboardcyclecount, ltrim(STR(Month(General_Counters_Table.Date_Time)))+ '/'+Ltrim(STR(Day(General_Counters_Table.Date_Time))) + '/'+ltrim(STR(Year(General_Counters_Table.Date_Time))) + ' hour ' +Ltrim(STR(Hour(General_Counters_Table.Date_Time))) as DATEConverted FROM General_Counters_Table where Date_Time >=(NOW()-1) and Date_Time <= (NOW()) GROUP BY General_Counters_Table.product_id, Year(General_Counters_Table.Date_Time), Month(General_Counters_Table.Date_Time), Day(General_Counters_Table.Date_Time), Hour(General_Counters_Table.Date_Time) ORDER BY Year(General_Counters_Table.Date_Time), Month(General_Counters_Table.Date_Time), Day(General_Counters_Table.Date_Time), Hour(General_Counters_Table.Date_Time)", Connection)
da1.Fill(ds1, "Throughput")
Connection.Close()
'Defines Chart and Chart Area
Dim chart1 = New Chart()
Dim chartarea1 As ChartArea = New ChartArea()
TabPage2.Controls.Add(chart1)
chartarea1.Name = "ChartArea1"
chart1.ChartAreas.Add(chartarea1)
Chart1.Location = New System.Drawing.Point(10, 10)
chart1.Name = "Chart1"
Chart1.Size = New System.Drawing.Size(800, 400)
chart1.TabIndex = 0
chart1.Text = "Chart1"
chartarea1.AxisX.LabelStyle.Angle = -60
chartarea1.AxisX.Interval = 1
chartarea1.AxisY.MajorGrid.Interval = 5
chartarea1.BackColor = Color.Azure
chartarea1.ShadowColor = Color.Red
chartarea1.Area3DStyle.Enable3D = True
chartarea1.AxisX.MajorGrid.Enabled = False
chartarea1.AxisX.LabelStyle.Font = New System.Drawing.Font("Times New Roman", 11.0F, System.Drawing.FontStyle.Italic)
'Legend
Dim legend1 As Legend = New Legend()
legend1.Name = "Legend1"
chart1.Legends.Add(legend1)
'Series
Dim series1 As Series = New Series()
series1.ChartType = SeriesChartType.StackedColumn
series1.ChartArea = "ChartArea1"
series1.Legend = "Legend1"
series1.Name = "Throughput"
chart1.Series.Add(series1)
chart1.Series("Throughput").XValueMember = "DateConverted"
chart1.Series("Throughput").YValueMembers = "sumofulboardcyclecount"
chart1.Series("Throughput").IsValueShownAsLabel = True 'shows label on datapoint
chart1.DataSource = ds1.Tables("Throughput")
chart1.Update()
chart1.DataBind()
End Sub