vb.net如何从访问查询中设置组合框

时间:2013-01-16 08:35:58

标签: vb.net ms-access-2007

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

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

1 个答案:

答案 0 :(得分:2)

如果您尝试连接到Access 2007,则需要使用其他提供程序

<强>提供商= Microsoft.ACE.OLEDB.12.0

请参阅此链接here