vb.net - 我的用户控件列表视图从 msaccess 填充数据的问题
问题描述
我通过 vb.net 在我的访问数据库中创建了 listview ms activex 我在 vb.net 中添加了该代码以填充我的 listview
Public Sub FillListview(ByVal CurrntDb As String)
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim itemcoll(100) As String
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.Items.Clear()
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & CurrntDb)
Dim strQ As String = String.Empty
strQ = "SELECT Accounts.ID AS [م], Customers.Customer AS [العميل], Accounts.Debit AS [مدين], Accounts.Credit AS [دائن], Accounts.Dates AS [التاريخ], Accounts.Notes AS [البيان] FROM Accounts INNER JOIN Customers ON Accounts.Customer_ID = Customers.Customer_ID;"
cmd = New OleDbCommand(strQ, conn)
da = New OleDbDataAdapter(cmd)
ds = New DataSet
conn.Open()
da.Fill(ds)
Dim i As Integer = 0
Dim j As Integer = 0
' adding the columns in ListView
For i = 0 To ds.Tables(0).Columns.Count - 1
ListView1.Columns.Add(ds.Tables(0).Columns(i).ColumnName.ToString())
Next
'Now adding the Items in Listview
For i = 0 To ds.Tables(0).Rows.Count - 1
For j = 0 To ds.Tables(0).Columns.Count - 1
itemcoll(j) = ds.Tables(0).Rows(i)(j).ToString()
Next
Dim lvi As New ListViewItem(itemcoll)
ListView1.Items.Add(lvi)
ListView1.Refresh()
Next
conn.Close()
End Sub
并在我的访问数据库中注册它并通过该代码在访问代码中调用它
Dim xlist As New AForTestListviewBySedo.UserControl1
Call xlist.FillListview("C:\Users\Elsayed\Desktop\New folder\mydb.accdb")
但他们什么也没有给我,不是错误,但什么也没有
我通过在其中添加按钮测试了用户控件中的代码按钮效果很好
我能做些什么 ?
解决方案
解决方案是使用我的代码访问通话记录我需要首先设置对象正确的代码是
Option Explicit
Option Compare Database
Public listv As MsAccessListviewACX1_00.UCBySedo
Public Sub LoadListview()
Set listv = Me.UCBySedo9.Object
listv.FillListview ("C:\Users\Elsayed\Desktop\New folder\mydb.accdb")
End Sub
Private Sub Command115_Click()
Call LoadListview
End Sub
推荐阅读
- php - 自动登录 WKwebview
- mysql - 实际解决方案与我的解决方案有什么区别?
- javascript - Electron构建访问静态图片vue js
- c++ - C++ 无法访问 PEB LDR InLoadOrderModuleList
- python - 如何使用 NumPy 生成具有条件概率的 x 和 y 样本
- django - Django 消息在管理员 model_save() 中不起作用
- appium - 无法使用 pycharm/appium 服务器(1.15.1)为移动应用程序定位元素(id)。但是 Appium Studio 可以找到相同的元素
- ruby-on-rails - 为什么我的创建表单没有工作,甚至没有响应?
- bash - 按包含特定字符的行将大文本文件拆分为块
- javascript - 如何使用 Axios 和 Express 将 React Array 数据插入 Mysql?