VBA Connect to MSSQL from Ubuntu

I have a small VBA macro that uploads a selected row to a MS-SQL database. The sheet works fine on Windows. I have now switched my PC over to Ubuntu and am trying to update the macro so that I can do these uploads there too.

The relevant part is the following.

      Set Cobj = CreateObject("ADODB.Connection")
      Cobj.Open "DSN=lXTC;Uid=Username;Pwd=secretPassword"

      For r = 0 To UBound(vSel, 1)
          vSQLi = "IF EXISTS (SELECT Date FROM ...."
          Cobj.Execute vSQLi
      Next

      Cobj.Close
      Set Cobj = Nothing

Now it throws an error saying it can’t load the module. I have installed the MS ODBC drivers on the Ubuntu machine and can connect to the database from the command line with isql -v lXTC username password

What do I have to change to connect to the database? Bonus solution would be, if both Windows and Ubuntu would work at the same time, cos I still have a Windows PC and then I could run it from both.

  • Create an ODBC connection. There is a program odbcinst.
  • Connect a Base document like this:
    menu:File>New>Database…
    Connect to existing, type ODBC, specify the name and create the query.