有人可以告诉我如何将vb.net 2010连接到ms访问数据库以获取数据并将其显示在我正在做的vb.net应用程序中.我的项目是我正在使用vb.net进行字典应用,所以每次我在搜索框中添加新单词时,我希望vb.net从ms访问中获取定义并将其显示在应用程序中.
代码片段很棒或者教程
'Grabs data from a table and posts it into a ListView Dim Table_ As String = "Table1" Dim query As String = "SELECT * FROM " & Table_ Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TestDatabase.mdb;" Dim ds As New DataSet Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_) cnn.Open() Dim cmd As New OleDbCommand(query, cnn) Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, Table_) cnn.Close() Dim t1 As DataTable = ds.Tables(Table_) Dim row As DataRow Dim Item(2) As String For Each row In t1.Rows Item(0) = row(0) Item(1) = row(1) Dim NextListItem As New ListViewItem(Item) ListView1.Items.Add(NextListItem) Next