Microsoft Access - 无法初始化数据提供程序

问题描述

我正在尝试使用 ADO 连接到远程数据库并在数据表表单上显示结果。我的代码如下:

Private Sub Form_Open(Cancel As Integer)
 Dim cn As ADODB.Connection
 Dim rs As ADODB.Recordset

 Set cn = New ADODB.Connection

 With cn
   .Provider = "Microsoft.Access.OLEDB.10.0"
   .Properties("Data Provider").Value = "sqlOLEDB"
   .Properties("Data Source").Value = "<server>"
   .Properties("User ID").Value = "<user>"
   .Properties("Password").Value = "<pass>"
   .Properties("Initial Catalog").Value = "<db name>"
   .Open
 End With
 
 Set rs = New ADODB.Recordset
 With rs
 Set .ActiveConnection = cn
 .source = "SELECT * FROM dbo.<table name>"
 .LockType = adLockOptimistic
 .CursorType = adOpenKeyset
 .Open

 End With

 Set Me.Recordset = rs

End Sub

显示记录,但它们是只读的,当我尝试排序或过滤时,我收到“无法初始化数据提供程序”。

我使用 Access 2016

DB 托管在 Azure 上

VBA 编辑器中的引用列表。

List of references in VB

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)