LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

record data to the database

Hi there, I'm using MySQL database to record data measured by LabVIEW. Ideally it should record 100,000data, but each time I run it and it can ONLY record 402 data and shows me an error below:

NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->record data.vi<ERR>ADO Error: 0x80040E14
Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.23]Duplicate entry '402' for key 'iqmeasurement.PRIMARY' in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->record data.vi.

 

I have no idea about what this error is and where iit's from. is there someone  help me with it? I've attached my code as well.

0 Kudos
Message 1 of 7
(1,343 Views)

Hi,

 

Have you checked that there is not already a value "402" in your key 'iqmeasurement.primary' ?

This error means that you have a primary key in you database structure (good) and that you are trying to insert a value that is already existing so to prevent it an error is raised.

 

Check what is inserted as your primary key and why there is a duplicate.

Message 2 of 7
(1,315 Views)

It looks like you are only recording one column (iincident) and you have it set as primary key.  This would appear to be a mistake.  If you need a primary key, create another column and set it as primary key.  It either case, you'll want to remove that option from iincident column. 

aputman
0 Kudos
Message 3 of 7
(1,283 Views)

You may want to reconsider how you are storing this data.  creating 100k records in a database for one test doesn't seem like a good idea to me.  Would it make more sense to store these values as a CSV string all in one record, with other fields to help identify the results (i.e. test name, date, etc?)

aputman
0 Kudos
Message 4 of 7
(1,275 Views)

Hi, thank you so much for your reply. actually, I only record incident at this moment, but I have another volume which is sample numbers, and I set it as primary key and make it as increment.

0 Kudos
Message 5 of 7
(1,237 Views)

Thank you for your reply. I have a column named sample numbers and set it as Primary Key and also make it as increment. so I don't think there is already a value "402". also, the value '402' is not the fix value, sometimes it shows me the error like Duplicate entry '2089' for key 'iqmeasurement.PRIMARY' in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->record data.vi. so I have no idea about what's the cause of it.

0 Kudos
Message 6 of 7
(1,218 Views)

Try to use a probe to know what data are going to be written and are failing. Then look to your database to check why there is this conflict.

 

Both errors '402' and '2089' are the same one.

0 Kudos
Message 7 of 7
(1,212 Views)