1

I have a very simple VBA code in Excel that queries a MariaDB database, using ADO, and then copies that recordset into Excel. The problem is that when the code is run on some machines, it works fine, and on others it returns, "Data provider or other service returned an E_FAIL status."

Dim sConn As String
Set adConn = New ADODB.Connection

If adConn.State = adStateClosed Then
    sConn = "Driver=MariaDB ODBC 3.0 Driver;" & _
        "Server=server;" & _
        "Database=database;" & _
        "User=user;" & _
        "Password=password;" & _
        "Option=3"
    adConn.ConnectionString = sConn
    adConn.Open
End If

Dim adRs As ADODB.Recordset
Set adRs = New ADODB.Recordset
    adRs.CursorLocation = adUseClient

Dim SQLQuery as String
SQLQuery = "SELECT * FROM table;"

adRs.Open SQLQuery, adConn, adOpenStatic, adLockPessimistic
    Worksheets("Sheet1").Range("A1").CopyFromRecordset adRs

Given that it works on some machines and not others, I imagine it may have to do with configurations or drivers on the computers themselves, rather than Excel, VBA, or SQL. Where should I look? All the machines are 64-bit, and the driver is a 64 bit driver. Is there something wrong in the code? In the connection string?

4
  • Are you trying to load a 64 bit driver on a 32 bit machine or visa-versa?
    – Comintern
    Nov 9, 2018 at 15:51
  • Have you poured through the configs of a working & non-working machine to identify where they differ?
    – FreeMan
    Nov 9, 2018 at 16:18
  • Great idea! Unfortunately, all of the machines are 64 bit, and the driver we're loading on all of them is 64 bit. Nov 9, 2018 at 16:19
  • I've tried - haven't noticed anything. What configs should I be looking for in particular? Nov 9, 2018 at 16:20

2 Answers 2

1

I cast the DATE fields as CHAR, and the error went away. I still don't know why some machines, running the same version of Windows, Excel, and the ODBC driver acted differently than others.

0

I coalesced NULLs to empty strings, and the error went away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.