01-28-2010 05:44 AM
Hi all
I have a 1D array of strings that I wish to write to a single MS Access record. Is there a quick and easy way of achieving this?
I am using LabView 9.0f3 and have the database connectivity toolkit.
I guess what I really want to do is either dump the entire array, as it is, in to a single, new Access record or maybe loop through the array, adding each element individually as a field in the new record.
Has anyone any experience of this or advice they can give me?
Thanks in advance.
Solved! Go to Solution.
01-28-2010 08:23 AM
leesi,
DB Tools Insert Data.vi should do what you need to do. Suggest you take a look at the examples for the Database Connectivity Toolkit that ship with LV.
01-28-2010 08:52 AM
I am not a db expert but have used the db toolkit quite a bit. A few items on each approach
1. Itterate through array and put each string item in its own field- potential problem is if your array size is not fixed and the order, meaning is unknown you might have a problem. That is the fields are relativly static and predefined in a database. This is great if the array each index has a special meaning and you might want to query on the fields. if index 0 = first name, index 1 = last name ....
2. write string array as string in single field. This is easy assuming you can format the array to a string that can be ulflattened like array to spreadsheet string. The problem with this is that the max size of a string is usually specified when you create the tables.
These are a few things I have come across when I tried something similar. I ended up going with the second example and it worked fine for me.
there are also many other things to try.
02-01-2010 10:14 AM
Hi guys
Thanks for your advice.
I managed to use the DB Tools Insert Data function but I struggled a little as the "Help" specifies that if the columns input is empty, the data will be stored in the database in the order it comes in in the data cluster. However, I couldn't get this to work. What I ended up doing was to create a columns array from the DB Tools List Columns VI and pass this through instead and it worked perfectly.
Cheers all
Lee
02-10-2010 02:02 AM
Hi Lee,
That 's right, "If the columns input is empty, the data will be stored in the database in the order it comes in in the data cluster. "
Find the example "Sixtypes Insert.vi", open its block diagram, then disconnect the column input of "DB Tools Insert Data", you will see the example still works well.
If you still can not get your VI work, please attach it so I can help you investigate where is the problem.
Thanks,
Kuan