LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database Connectivity Toolkit (multi row insert)

Solved!
Go to solution
Also - you can do this as a single insert - like this:
INSERT INTO table (value,name) VALUES (1.123,Temp1), (2.123,Temp2), (5.1235,Temp3);

LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 21 of 31
(2,084 Views)

Hello aputman,

I've tried what you suggested but unfortunately it didn't work and I still get the same error.

As for what you suggested Sam, I can't do that because my values are generated by the DaqAssistant.

0 Kudos
Message 22 of 31
(2,071 Views)

I never tried the syntax suggested by Sam, but certainly you can reproduce it modifying the code in your loop.

The string "INSERT INTO table (value,name) " should be injected into the shift register, then you should add your value pairs properly.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 23 of 31
(2,061 Views)

You have misunderstood what I suggested, in your for loop, you generate N queries (one for each channel). Instead of that, generate a single query with N VALUE sections, like this:

Multiple Insert.png

 It has the exact same structure as your existing code but does the inserts in a single query.

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 24 of 31
(2,057 Views)

I'm sorry I didn't understand you at the beginnig, I tested that and I have the same string query as you showed me. But now I have an error that says that "Column count doesn't match value count at row 1". I'd like to inform you that my database table has two columns (value & channels).

0 Kudos
Message 25 of 31
(2,049 Views)

Try your question in the database, e.g. SQL manager, and/or build the question there as a reference to how you need to formulate it in LV.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 26 of 31
(2,044 Views)

It seems like the decimal separator where the problem was, I added %.; to my query and now it works.

Thank you so much for your help, I really appreciate.

Message 27 of 31
(2,042 Views)

@AhciaDa wrote:

Hello aputman,

I've tried what you suggested but unfortunately it didn't work and I still get the same error.

As for what you suggested Sam, I can't do that because my values are generated by the DaqAssistant.


Well, of course it won't work if you don't incorporate all of the advice you have been given.  Smiley Frustrated

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 28 of 31
(2,035 Views)

I did incorporate them and it works well now.

Thank you very much.

0 Kudos
Message 29 of 31
(2,026 Views)

Hello,

 

I try to insert multiple values in .mdb database using standard microsoft jet oledb connection.

My query is:

INSERT INTO T_Column (C_Name)

VALUES ('1') , ('2');

 

I use NI_Database_API.lvlib: DB Tools Execute Query.vi

I get the error -2147217900: "

L'erreur -2147217900 s'est produite à : NI_Database_API.lvlib:Conn Execute.vi->Add_Multiple_Columns_onDatabase.vi->Test_Create_big_database_optim.vi

Raisons possibles :
ADO Error: 0x80040E14
Exception occured in Microsoft JET Database Engine: Point-virgule absent à la fin de l'instruction SQL. dans NI_Database_API.lvlib:Conn Execute.vi->Add_Multiple_Columns_onDatabase.vi->Test_Create_big_database_optim.vi"

It indicates that the semicolon character is missing in the query...

 

I think that I can not execute multiple query because the request below works:

INSERT INTO T_Column (C_Name)

VALUES ('1') ;

 

What do I have to do to correct this?

I really need help urgently! Thanks for your help!

0 Kudos
Message 30 of 31
(1,764 Views)