我的版本VB 2010
資料庫採用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
我的版本VB 2010
資料庫採用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