LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Object not valid InsertData SubVI

Solved!
Go to solution

Hi Everyone,

I'm still getting the grasp of Labview (i'm working with it for a month now) and i stumbled upon an error:

 

the code pick data from various thermocouples, then i pack them and loop the insert data VI to write the database, it worked fine for days, until i received the error attached "object not valid".

 

I really can't figure out what's the problem i didn't have any issue whatsoever for days with this code.

 

Can you guys please help me?

Download All
0 Kudos
Message 1 of 6
(268 Views)

There's no way to tell without seeing all the code, or at least all database related code.

 

Try if you can make (post) a SSCCE...

 

It sure sounds like a (not closing a) reference problem...

 

Why do you disconnect  the connection every iteration? Why not open the connection once, and re-use it? Or open the connection every time the connection is disconnected...

 

What kind of database is it? Access? SQLServer? Excel? You can even make a ODBC connection to a .txt file database... Opening an excel file can block it for remove connections, so you might get an error if you open the database.

0 Kudos
Message 2 of 6
(233 Views)

First of all thanks for your time!

I'm sorry if my infos are not enough i will give you more infos but first let me answer your questions:

i close the connection because labview doesn't seem to "commmit" the write in the DB when the program is running, and it eats ram really fast, resulting in an error after few minutes. Closing the connection after the iteration resolved this issue for me.

 

anyway the program is in a while loop (i don't know if it's a common practice or not because it is what i found when i arrived in my company) and collects various signals from daq assistant, then the results are splitted and packed in bundles (this is the screenshot part) and inserted in the DB (MSSQL EXPRESS 19) located in the same machine, that's it.

I uploaded the entire file

 

Thanks again for your support

0 Kudos
Message 3 of 6
(224 Views)
Solution
Accepted by topic author Jojoee

You open the database each iteration, so you should close it each iteration.

 

But as it is, you open the database once, and close the reference 3X. So, inserts in the for loop only work until one for loop is finished. Then, the database is closed and all other inserts fail.

 

Either pass the reference from one for loop to the next and close once after the last, or synchronize the close so it executes once when all loops are finished (for instance with a Synchronize Data Flow, a Flat Sequence Structure, by merging the errors, etc.)..

 

Or, open it once, and close it once. Move the open and close outside the loop...

 

Or open it on error, close it once when the loop stops.

 

 You might start thinking about making SubVIs. Divide and concur and all that... There are a lot of downsides to having all your code in one big VI.

Message 4 of 6
(182 Views)

That was it! Handling the close connection separately seems to resolve my problem. I'm still a bit confused about how it was able to run flawlessly until i got this error.

I will now focus on making a polished subVI for this operation as you suggested.

 

Thank you very much!

Message 5 of 6
(157 Views)

@Jojoee wrote:

I'm still a bit confused about how it was able to run flawlessly until i got this error.


If the execution order isn't defined (by enforcing it), it's undefined. It might work by coincidence or luck and stop working for unknown reasons: it's undefined...

 


@Jojoee wrote:

I will now focus on making a polished subVI for this operation as you suggested.


That's one of the hardest things to do correctly, but that's certainly no good reason not to start doing it! 😎 Good luck!

0 Kudos
Message 6 of 6
(139 Views)