0

我有这样的代码(还没有完成,因为我不知道访问连接设置)

 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 列表。我怎么做?此连接是否不正确,还是我仍需使用数据集向导?

4

1 回答 1

2

如果您尝试连接到 Access 2007,那么您需要使用不同的提供程序

提供者=Microsoft.ACE.OLEDB.12.0

请在此处参考此链接

于 2013-01-16T09:40:48.977 回答