07-06-2006 11:04 AM
Hi,
The problem is that we are trying to build an application as generic as possible. We have to write some data to an Access database. The number of columns is subject to change from a system to another (between 20 and 100).
The function "Insert data" in the database connectivity requires some kind of cluster. After each part is processed by our system, I want to write the data (which is an array) to the database. I know I can use the bloc "Array to Cluster" and "hardcode" the cluster size. It will work for a specific application. But then, when I have another application with a different number of columns (different data size) in my database, I have to change this value in the bloc "Array to Cluster" and build another application? This is very inconvenient.
So I want to know if there is any way to transform my data before I input it in the "Insert Data" function to make my application generic. I have been trying a lot of things, and it appears that this function really needs a structure with a fixed size.
Thanks for your help
alexandre boyer
07-06-2006 11:32 AM
There is a limit to how much you can (and should) make an application generic and you should probably rethink your design. In general, you should have no interaction with the tables in your database. Instead, you should have VIs which will be assigned specific functionalities and will hide the structure of the actual saved data.
For example, suppose your application performs a test and then saves the results. These tests are defined in your DB. In this case, you could create a VI called "Save test data". That VI would accept a data structure (let's say a typedef cluster or an array) representing the test data and would then internally be responsible for saving that data. If your DB is properly designed, it is possible that the VI will need to go to several tables in order to process the data, but the point is that the VI will handle the saving of the data without any need for the application to know how it's doing it.
You create functions like that for everything you want to do. That way you sever the link between the application and the DB. Once you do this, of course, you have no need to have a general conversion from an array to a cluster.
I suggest you try searching the forum for a document Mike Porter posted about working with DBs. It might help you.
07-06-2006 01:51 PM
07-06-2006 02:25 PM
07-10-2006 03:35 PM
Hi,
Thank you all for your responses. I am considering a spreadsheet to save the data.
The point is that we are implementing our product on different machines with different sizes. The actual client is using an Access database for a long time with a debatable structure. He wanted us to incorporate our data in it using the same kind of structure he already has, but I don’t want to uses cases, just in case he comes with another machine with another size. And I certainly don’t want to compile many different applications doing the same thing.
Anyway, the client agreed with the spreadsheet, so everything is nice.
I really appreciated your help.
Thanks
Alex boyer