Showing results for 
Search instead for 
Did you mean: 

Error 505 occurred at DB Tools Close

I get the following error when running my vi:
Error 505 occurred at DB Tools Close >
Possible Reason: Open Command Object.
My vi (DataEntry) opens an ODBC connection. The connection reference is passed to a loop that executes SQL commands (and frees the recordset reference after each command) . Upon completion of the loop, I close the connection reference with "DB Tools Close
Seems simple enough, yet I get this error when trying to close the connection. No errors are generated by the vi's for opening, commanding, or freeing record references.
Any help would be appreciated.
Rich Burbage
0 Kudos
Message 1 of 12

Hi Rich,

Are you able to locate the source of the open command object that may be the cause of the error you receive?

I've encountered this error before. However, the best workaround I could find was to avoid the error cluser on the DB close altogether. My vi still functioned properly but I had to follow up with R&D to tackle the bug-like behavior regarding the error.

Does your program work properly despite the error message?




0 Kudos
Message 2 of 12
Another possibility is to simply close the reference yourself not using their subVI. All the close really needs to do is call the ADO Close method for the connection object that was opened earlier, and then close the object reference itself using the Close Reference function.

Part of the problem with troubleshooting this is trying to figure out what extra fru-fra the DCT is imposing on what is basically a pretty simple process. If you would like to try them, I posted the VIs that I use for all my database work a while ago on the forum. If you can't find them let me know and I'll repost them in LV8.2. The main difference with the DCT (beside the fact that I don't have the cajones to try and charge for them) is that for the most part they are a very thin layer sitting on top of the ADO drivers. The main advantage of this approach is that if you are troubleshooting it's a lot easier to figure out what is happening.

By the way, unlike what you might expect, the Microsoft documentation on ADO is really good.


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."
Message 3 of 12
Were you able to fix or bypass the error?? I have also encountered the same and its occuring randomly.
As eek said, If we avoid the error cluster connected to dbclose vi, is it healthier option to do??
0 Kudos
Message 4 of 12
I ended up avoiding the error by throwing it away. We have not encountered any noticable problems, but I am not convinced it is a "healthy" method. I have not discovered the reason behind the error. We use the same approach in several vi's, but only one has this problem.
Rich Burbage
0 Kudos
Message 5 of 12

HI all,

                            According to my R&D its not DB close connection where error is generated. Please read the description here

Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
0 Kudos
Message 6 of 12

I had been receiving error 505 also when Closing the Database Connection reference.

I’m calling the Create Parameterized for a stored procedure, then the Execute, and the Fetch Record Set I had the DB Tools Free connected to the output of the Fetch.

I found that the Create Parameterized and the Execute output different Object references and both need to get freed separately. Now the error is gone.

0 Kudos
Message 7 of 12



i have the same error. Can you please post a image of your solution.



0 Kudos
Message 8 of 12

Hello Schwede,


This is an old thread so I am not sure it is still being followed. I would suggest you to create a new thread including your code to see if your question gets more visibility among users. You can even post this thread to give some more context, but definitely having more details about the error message you are getting would be quite useful.

0 Kudos
Message 9 of 12

How about posting your code. This is an error that is cause by faulty programming.



Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."
0 Kudos
Message 10 of 12