Sub BindChart()
Dim cmd As DataTable = connectdb.GetDataTable("SELECT COUNT(Topic_ID) AS Pos_Count, month, year FROM tblTopic_Report GROUP BY month, year")
If cmd.Rows.Count > 0 Then
Me.chart_Static.DataSource = cmd
Me.chart_Static.Series("Series1").ChartType = SeriesChartType.Line
Me.chart_Static.Series("Series1")("DrawingStyle") = "Emboss"
Me.chart_Static.Series("Series1").XValueMember = "month"
Me.chart_Static.Series("Series1").YValueMembers = "Pos_Count"
Me.chart_Static.Series("Series1").IsValueShownAsLabel = True
Me.chart_Static.DataBind()
Else
MsgBox("ไม่พบข้อมูลกราฟที่ต้องการแสดง")
End If
Dim cmd2 As DataTable = connectdb.GetDataTable("SELECT COUNT(Ans_ID) AS Ans_Count, Ans_month, Ans_year FROM tblAnswer GROUP BY Ans_month, Ans_year")
If cmd2.Rows.Count > 0 Then
Me.chart_Static.DataSource = cmd2
Me.chart_Static.Series("Series2").ChartType = SeriesChartType.Line
Me.chart_Static.Series("Series2")("DrawingStyle") = "Emboss"
Me.chart_Static.Series("Series2").XValueMember = "Ans_month"
Me.chart_Static.Series("Series2").YValueMembers = "Ans_Count"
Me.chart_Static.Series("Series2").IsValueShownAsLabel = True
Me.chart_Static.DataBind()
Else
MsgBox("ไม่พบข้อมูลกราฟที่ต้องการแสดง")
End If
End Sub
ประมาณนี้ครับ พอรันมันขึ้ันแบบนี้
Column with name 'month' was not found.
Line 34: Me.chart_Static.Series("Series2").YValueMembers = "Ans_Count"
Line 35: Me.chart_Static.Series("Series2").IsValueShownAsLabel = True
Line 36: Me.chart_Static.DataBind()
Line 37: Else
Line 38: MsgBox("ไม่พบข้อมูลกราฟที่ต้องการแสดง")
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET, VS 2010 (.NET 4.x)