09-27-2022 05:06 AM
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.
09-27-2022 06:15 AM
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.
09-27-2022 02:04 PM
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.
09-27-2022 02:14 PM
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?)
09-28-2022 02:49 AM
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.
09-28-2022 03:40 AM
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.
09-28-2022 03:49 AM
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.