Looks like SQLDisconnect() handling with MariaDB ODBC driver is not cleaning up the information properly. Either that or SQLDriverConnect() should properly set the new value from the connection string. In my case, call to SQLDriverConnect() after SQLDisconnect() complained about database name of the previous connection!
Please see the attached standalone program along with the output. If I use MySQL ODBC driver, then I don't see the same issue. Standalone program uses both MariaDB and MySQL ODBC drivers.