LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write a specific column data in database

Hello All,

I am using the database connectivity tool kit to read data from .accdb file, I can able to write all the data in to database but not able to write only specific data column in to database. Please suggest.

0 Kudos
Message 1 of 10
(2,901 Views)

Hi Swasa,

There are two ways to read the column information from the database.

way1: Execute the query "

select * from <Column Name>

using the  'DB Tools Execute Query.vi> inside the 'Database\Advaced' palette.

 

Way2: Use the 'DB Tools List Columns.vi' from the  'Database\Utility' palette and use the LV functions to filter out the not required data 

 

Regards,

Srikrishna

Regards,
Srikrishna


0 Kudos
Message 2 of 10
(2,864 Views)

If I understand correctly, you'll want to look at UPDATE statements to be able to change the values stored in a single column (it may be that you can only do this one row at a time, in which case use a For loop as needed).

You can't usually enter data into a database table with only one column, unless the other columns all have either defaults or allow null.

The SQL syntax to do that would be

INSERT INTO <table> (<column name 1>) VALUES (<value 1>);

where you can choose an arbitrary collection of columns, but must give one value per column (e.g.)

INSERT INTO <table> (<column name 1>, <col 2>) VALUES (<value 1>, <val 2>);

It looks like these operations should be available without requiring an executed manual statement though - see

DB Tools Insert Data (wire the columns array to specify columns)

DB Tools Update Data


GCentral
Message 3 of 10
(2,855 Views)

Could you please provide an example, because I tried using insert in to data db vi, using this I can write all the column values but not specific column. My end goal is - I have an1D array and I need to add all the array values in one of the column. Hope this is clear. Thanks

0 Kudos
Message 4 of 10
(2,821 Views)

I would expect the following to be what you're looking for:

Example_VI_BD.png


GCentral
Message 5 of 10
(2,812 Views)
0 Kudos
Message 6 of 10
(2,799 Views)

Thank you!. Yes I tried it, but it  is updating always with last value ( refer screenshot)

0 Kudos
Message 7 of 10
(2,792 Views)

I think you can simplify your Database read to 2Darray by replacing the double for loop with a 2D string array constant to the Variant to data.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 10
(2,788 Views)

Solved!! 🙂 Thanks everyone. I have added a condition!

Message 9 of 10
(2,784 Views)

@swasa wrote:

Solved!! 🙂 Thanks everyone. I have added a condition!


Oops! Sorry, you mentioned inserting previously so I though you were going to have default values in the other columns.

For update (as you already found) you can use a condition (like WHERE blah=<value> in SQL) to only update specific rows, or else all are updated, repeatedly, leading to them finally all having same value as you saw! (earlier in the VI's execution, they'd all have the value 1, then 2, then 3, etc).


GCentral
0 Kudos
Message 10 of 10
(2,782 Views)