访问筛选器不适用于ADODB.Recordset连接err(无法初始化数据提供程序

时间:2018-11-06 22:39:39

标签: mysql vba ms-access odbc

我们已经将Access数据库的一部分迁移到mysql,此代码段仅从包含表单名称和sql语句的表中检索sql语句,然后将其设置为表单记录集

我现在遇到的问题是,尽管速度有了很大的提高,但是访问前端现在还没有完全按预期运行,通过文本访问功能进行的刷新和筛选不起作用,只是引发错误(数据提供者可以尚未初始化)。

我相信这与我们将记录源设置为表单有关,无论如何,这不会造成性能大幅下降吗?

如果我只是将mysql的一个视图链接到access并将窗体recordsource设置为该视图,则加载和过滤所花费的时间要长得多

这里的图片http://puu.sh/BXw55/fe8b01d8d0.jpg显示尝试使用访问过滤器时发生错误的时间

以下是函数:

Private Sub Command91_Click() 'Clear filters'
On Error GoTo ErrHandler
Dim oConn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim ConnStr As String
Dim strOrderBy As String

'Creating new connection, and then using ConnectString function to connect to mysql Database'
Set oConn = New ADODB.Connection
oConn.Open ConnectString

'Clears filter fields to null'
fltrDocBaseID.Value = Null
fltrDocBaseClientDocNumber.Value = Null
fltrDisciplinesID.Value = Null
fltrDocTypeID.Value = Null
fltrDocSubTypesID.Value = Null
fltrProjectID.Value = Null
FilterOn = False
fltrDocBaseTitle1.Value = Null
fltrDocBaseTitle2.Value = Null
fltrDocBaseTitle3.Value = Null
fltrDocBaseTitle4.Value = Null

'Retrieves SQL code from refreshDS(fname As String) located in Module- SQLDatasources'
strSQL = refreshRS(Me.Name)
'Creates new recordset'

Set rs = New ADODB.Recordset
'Connects to mysql database, runs strSQL and then sets page recordset'
'to the current strSQL'
With rs
    Set .ActiveConnection = oConn
    .Source = strSQL
    .LockType = adLockOptimistic
    .CursorType = adOpenKeyset
    .CursorLocation = adUseClient
    .Open
End With

Set Me.Recordset = rs
'Closes recordset and connections, This is a good practice for traffic efficiency'
rs.Close
oConn.Close
Set rs = Nothing
Set oConn = Nothing

0 个答案:

没有答案