1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
' Resolve the address to the Access database
Dim myConnectionString As String = ConfigurationManager.AppSettings("BD")
' Define the database query
Dim ID As Integer = 1
Dim mySelectQuery As String = "SELECT Id, Name,Header,Value,couleur from tab 1 where Id=1"
' Create a database connection object using the connection string
Dim myConnection As New OleDbConnection(myConnectionString)
' Create a database command on the connection using query
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
' Open the connection
myCommand.Connection.Open()
' Create a database reader
Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Since the reader implements and IEnumerable, pass the reader directly into
' the DataBindTable method with the name of the Column to be used as the XValue
'Chart1.DataBindTable(myReader, "Header")
With Chart1.Series("Series1")
.ChartType = SeriesChartType.Column
.Points.DataBindXY(myReader, "Header", myReader, "value")
.Palette = ChartColorPalette.Fire
End With
' Close the reader and the connection
myReader.Close()
myConnection.Close()
End Sub |
Partager