0
我要查看該數據的圖表在我的數據庫 我想這個代碼,但我得到一個錯誤信息查看在VB利用訪問數據庫中的數據圖表
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Chart1.Series.Add("Total number of Orders for each Company")
Dim Conn As OleDbConnection = New OleDbConnection
Dim provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
Dim dataFile = "F:\College Files\Co-op Files\Aramco Project\Application\OrdersApplication\OrdersApplication\Database.accdb"
Conn.ConnectionString = provider & dataFile
Conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand("SELECT [CompanyID], (SELECT COUNT(QuantityRequired) FROM Order_Details) FROM [Orders] ", Conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read
Chart1.Series("Total number of Orders for each Company").Points.AddY(dr("CompanyID").ToString, dr("QuantityRequired").ToString)
End While
dr.Close()
cmd.Dispose()
End Sub
錯誤消息說QuantityRequired在此行的附加信息
Chart1.Series("Total number of Orders for each Company").Points.AddY(dr("CompanyID").ToString, dr("QuantityRequired").ToString)
當我刪除指望它顯示出來,但我需要它來計算每家公司ID
謝謝你的工作,但結果是錯誤的圖表我不知道爲什麼 –
我想你需要過濾訂單ID。請參閱編輯。 – Gustav
非常感謝 –