Jan. 15, 2016, 7:54 a.m.

qODBC Fails to Launch QuickBooks

I recently ran into an interesting issue where the qODBC bridge we use to connect to QuickBooks from our custom application would fail to properly initialize QuickBooks. In principal the qODBC bridge is an ODBC driver that connects to QuickBooks via QuickBooks's API by launching an instance of the actual QB GUI and then communicating that way with it. It follows that our custom application connects in turn to qODBC to perform database related calls to QuickBooks.

Recently after a server patching we started receiving these error messages when trying to connect to QuickBooks:

Unhandled Exception: System.Exception: Cannot connect to QuickBooks: ERROR [00000] [QODBC] QB Begin Session Failed. Error = >80040408, Could not start QuickBooks. ERROR [00000] [QODBC] QB Begin Session Failed. Error = 80040408, Could not start QuickBooks. ---> System.Data.Odbc.OdbcException: ERROR [00000] [QODBC] QB Begin Session Failed. Error = 80040408, Could not start QuickBooks.

A support request with qODBC did not go anywhere - everything they recommended I have already tried. So I rolled up my sleeves and used my grey matter:

  1. First things first - the configuration of the system is as follow. QuickBooks, qODBC, the custom application and the company files are stored on server A, a file server. QuickBooks also run on server B, a terminal (Remote Desktop) server. Staff use QuickBooks on server B for their day to day work, accessing company files from server A. The company file is in multi user mode.
  2. I discovered that if anyone has the company file open in QuickBooks on server B, the custom application would fail to load QuickBooks. If I had QuickBooks open with the company file on server A, it would work.
  3. This sounded like a network / file sharing issue at its core, though the obvious symptoms did not reflect this. I looked at the status of QuickBooks Database Server Manager - the app that helps with the sharing of company files across servers and dealing with multi user access issues. I found the status was STOPPED. Trying to start it by launching QuickBooksDB26 service did not work - the service started the stopped with this error in the event log:

    Could not start server

    not very helpful. Looking at C:\ProgramData\Intuit\QuickBooks\DBStartup.log revealed a bit more insight:

    Unable to initialize requested communication links
    Error in command near "-1M"

    this pointed me to perhaps a port issue.

  4. The problem is I did not know which ports this new SQLANY 16.0 DB instance was using. A peek in QBGLOBALAPPCONFIG.INI showed that it seems to be high ports above 55333 that is in use. I checked netstat and found that dns.exe has ports 55333 and around open. Now this is UDP and I was under the impression the DB is TCP - but it was a shot worth trying. I remember from past experiences that DNS sometimes starts before other services and then a race condition ensues for the relevant ports. It is possible to exclude certain ports in the registry for DNS but this will not work as the ports for QuickBooks is dynamic too.
  5. I stopped DNS, started QuickBooksDB26 (sometimes it still fails - just wait 2 minutes), then started DNS again. DNS used other ports and everything worked well. In QuickBooks Database Server Manager I initiated a Scan and everything was working.