我有這樣的代碼集組合框(仍然沒有完成,因爲我不知道接入連接設置)vb.net如何從訪問查詢
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim golmin As String
golmin = ComboBox1.SelectedText
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:/Users/RUMAH49/Documents/Visual Studio 2008/Projects/Project-Christian/Project-Christian/MineralDB.mdb"
con.Open()
sql = "SELECT [Nama Mineral] FROM MsMineral WHERE [Golongan Mineral] LIKE '" + golmin + "'"
da = New OleDb.OleDbDataAdapter(sql, con)
End Sub
我要來用的combobox2列表上面的查詢。我怎麼做?這個連接是不正確的還是我仍然必須使用數據集嚮導?
連接字符串可以從http://connectionstrings.com得到,例如'Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\ mydatabase.mdb;'爲什麼你有斜槓而不是反斜槓?您的路徑太長,MS Access無法正常工作。 – Fionnuala
@Remou +1注意斜槓 – AbZy