09-30-2019 05:25 PM
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.
09-30-2019 07:31 PM
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
09-30-2019 08:04 PM
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)
10-01-2019 01:31 AM
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
10-01-2019 01:58 AM
10-01-2019 03:24 AM
10-01-2019 04:00 AM
Thank you!. Yes I tried it, but it is updating always with last value ( refer screenshot)
10-01-2019 04:12 AM
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
10-01-2019 04:20 AM
Solved!! 🙂 Thanks everyone. I have added a condition!
10-01-2019 04:25 AM
@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).