我试图允许用户选择他们想要从哪个表中获取数据,UserID文本框(UserIDtb)是用户输入他们想要的表的位置。我已经尝试了几种不同的方法,但似乎不允许用户选择特定的表。这是我到目前为止的代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConfirmIDButt.Click
Chart1.Series.Add("Score")
Dim Conn As OleDbConnection = New OleDbConnection
Dim provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
Dim dataFile = "\users.accdb" ' Change it to your Access Database location
Conn.ConnectionString = provider & dataFile
Conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand("SELECT [Month], [Score] FROM [Table]", Conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read
Chart1.Series("Score").Points.AddXY(dr("Month").ToString, dr("Score").ToString)
End While
dr.Close()
cmd.Dispose()
End Sub