For i As Integer = 1 To 5
Sql = "select type_dt,usetime " & _
"from Logdowntime " & _
"where id_dep = '" & i & "' " & _
"group by type_dt "
Dim da As New SqlDataAdapter(Sql, objConn)
Dim ds As New DataSet
da.Fill(ds, "tb")
'*** BindData to Charts ***'
Dim cht As New Chart
cht = CType(Me.Controls("Chart" & i), Chart)
With cht
.DataSource = ds.Tables("tb") '<<< มันขึ้น Error ที่บรรทัดนี้ะครับ Object reference not set to an instance of an object.
.Series("Series1").ChartType = SeriesChartType.Column
.Series("Series1")("DrawingStyle") = "Emboss"
.Series("Series1").XValueMember = "type_dt"
.Series("Series1").YValueMembers = "usetime"
.Series("Series1").IsValueShownAsLabel = True
.Series("Series1").IsVisibleInLegend = False
.Size = New System.Drawing.Size(325, 300)
.DataBind()
End With
Next
Tag : .NET, Ms SQL Server 2008, VB.NET, VS 2010 (.NET 4.x)