偶的版本VB
在窗体上添加1个Chart控件,1个按钮。
数据库采用ACCESS数据库
代码如下:
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnOle1 As New OleDbConnection
myConnOle1.ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Application.StartupPath & “\数据库.Mdb”
myConnOle1.Open()
Dim myCommand As OleDbCommand = New OleDbCommand(“SELECT 姓名,成绩 From 表2”, myConnOle1)
Dim myreader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Chart1.DataBindTable(myreader, “姓名”)
End Sub
End Class