qodbc connection won't close? (can't close QB after QODBC use) |
Author |
Message |
Mike |
|
Group | : Members |
Posts | : 7 |
Joined | : 2006-06-17 |
|
Profile |
|
Posted : 2006-09-27 09:58:35 |
I am using an ADODB Connection and RecordSet to access QB through QODBC. I can step through my code and verify that I call close() on both the recordset and the connection before my app terminates. After it terminates, I can not close the QB file without going into TaskManager and killing it there. The message I get is: The company file cannot be closed at this time because there is another application (addin product or background task) which is using it. You must close that application before you can close the company file.
I am getting this message after I have closed the recordset and the connection and after my app has terminated and is no longer running.
Thank you for any suggestions-
Mike |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-09-27 11:23:58 |
If your application is running as a service, or through a service, it may take up to ten minutes for the O/S to release the actual connection. |
|
|
|
Mike |
|
Group | : Members |
Posts | : 7 |
Joined | : 2006-06-17 |
|
Profile |
|
Posted : 2006-09-28 07:15:42 |
No just a regular application and it is still locked up 30 minutes after it has terminated.
Why doesn't the driver free the connection when we call close()? |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-09-28 08:30:37 |
You didn't say what you are using to build your application. Products like MS Access don't actually close the connection until Access is closed. You can also have this situation arise when invalid commands are sent to QODBC. For example, if I clause a Windows Exception error, or an infinity loop, I will need to close QuickBooks using the Task Manager. |
|
|
|
|
Posted : 2006-10-10 12:33:07 |
I'm using VB.NET and receive the same error as described in the original post. It happens consistently without fail. It's not practical to have my end-users opening Task Manager to kill the process.
Is there a fix for this? |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-10-10 12:58:05 |
If your VB.NET application is running as a service, or through a service, it may take up to ten minutes for the O/S to release the actual connection after closing the connection. It's the Windows O/S that holds onto the connection, not QODBC.
However, if you issue invalid SQL statements to QODBC from your VB.NET application that result in exception errors or hangs, then the driver will be left in memory after the crash and QuickBooks won't close either. |
|
|
|
|
Posted : 2006-10-12 06:18:48 |
I rely on the error messages from QB, and handle them appropriately in my app; this isn't atypical component design. For example, rather than querying QB to determine the existence of a Job:Estimate record (which is a time costly operation) I simply perform my insert and trap for the QB duplicate error. Does this mean my connection to QB will be unable to close properly? If so, this introduces several problems:
1. If my app opens QB in the background, performs its actions and exits, the end-user cannot subsequently open QB; instead, they receive an error that reads something like: "cannot open QB; data is currently being shared by an interactive application".
2. If my app connects to an open QB interface, performs its actions and exits, the end-user cannot subsequently close QB; instead, they receive an error that reads something like: "cannot close QB; data is currently being shared by an interactive application".
3. Either way, the end-user cannot logoff from their Windows account or restart their machine.
Please advise. Does QODBC handle this any better? Is there an override flag for the QB exit operation? Are they any practical workarounds? Thanks in advance. |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-10-12 09:54:08 |
We have asked Intuit to add an override to this message to close anyway, but they have not yet provided it. Duplicate errors are not a problem and I do them a lot in testing anyway, but because you are coding to do errors all the time I think you might be missing things like invalid values, missing values or syntax errors that are causing QODBC to hang and therefore be left in memory.
You might even be just opening connections without closing them. I suggest you create a small test program to investigate further. |
|
|
|