目前,我已成功将MS Access中的数据从本地LAN获取到listboxview。
我们在远程服务器中有另一个Access文件,我们将其映射为S驱动器,即S:\ dbfile \ test.accdb。我正在尝试以下字符串从远程服务器获取数据。但是,数据不会填充,也不会抛出错误。
con = New OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0;Data Source=s:\dbfile\test.accdb")
下面是用于填充列表框视图的代码
Sub datapopulate()
Dim connection As OleDbConnection
Dim command As OleDbCommand
Dim data_reader As OleDbDataReader
'setup listview
connection = New OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0;Data Source=s:\dbfile\test.accdb")
connection.Open()
'reading data from table
command = New OleDbCommand("SELECT * FROM tbllist", connection)
data_reader = command.ExecuteReader
'add data to listview
If data_reader.HasRows Then
While data_reader.Read
Dim newitem As New ListViewItem()
newitem.Text = data_reader.GetValue(2) 'first column
newitem.SubItems.Add(data_reader.GetValue(3)) 'second column
newitem.SubItems.Add(data_reader.GetValue(5)) 'second column
newitem.SubItems.Add(data_reader.GetValue(6)) 'second column
ListView1.Items.Add(newitem)
End While
End If
End Sub
有没有人知道为什么数据没有填充?