LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write a 1D array to an MS Access record

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(4,310 Views)
Solution
Accepted by topic author leesi

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.

Message 2 of 5
(4,295 Views)

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.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 5
(4,289 Views)

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

0 Kudos
Message 4 of 5
(4,257 Views)

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

0 Kudos
Message 5 of 5
(4,175 Views)