Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

XNET Change Database Keep Alias

I have a need to allow users to change a database file used in an XNet database at run-time.  My intention was to start by deleting a database with a constant name something like "XNet Database".  If this alias doesn't exist then the Remove Alias will return an error which I just clear because I don't care.  Next I use the Add Alias and set the database name to "XNet Database" using the new file the user provides.

 

Then if the user chagnes the database file to a new one, my software performs a Remove on "XNet Database" and then an Add using the new file.  The problem is after doing the remove and then add, all references to the "XNet Database" will be for the first file, not the second one the user choose.  If I close the software and re-open then it will use the new alias.  So is there a way to force a close of a database in the software, so that I can use the same database name, but assign a new database file?

 

I also tried generating random database names.  Something like "XNet Database %d" where %d can be a random number.  In my code I still remove all aliases, then add an alias using the new file the user selected.  The problem with this is after doing this 7 times I get the following error:

 

Error -1074384592

 

NI-XNET:  (Hex 0xBFF63130) Too many open files. NI-XNET allows up to 7 database files to be opened simultaneously. Solution: Open fewer files.

 

So this confirms my suspicions that the database is still in memory, even after performing the remove alias.  How can I force a close of a database, so that I can allow my users to use a new database file?

 

EDIT: okay so I missed the Close Database Polymorphic.  Doing a Close All before the remove seems to fix it.  If I don't close all and just try to close that one database it doesn't work.  In my situation I think I can live with just closing all.

0 Kudos
Message 1 of 1
(5,631 Views)