Solution
This error means that there is a data type mismatch between what the LabVIEW Database Connectivity Toolkit is writing and what the database expects to receive. Follow these recommendations to address the issue:
- Use the available data types in the LabVIEW Database Connectivity Toolkit and map them to the appropriate data type in the SQL database. The LabVIEW
Database Connectivity Toolkit User Manual defines the supported data types in Chapter 4.
- For example, if you try to write a boolean value in LabVIEW (True or False constant) to a SQL column of the type numeric, error -2147217913 will be reported.
- Make sure you are writing data in the form and order the database is expecting. For example, if you are writing a cluster of 2 elements in LabVIEW, make sure the data type of those two values are compatible with the column data type definition configured in the database.
In the following image, assuming there are two columns in the table, one having a varchar definition and the other one a numeric definition, the VI will return error -2147217913, as it tries to write a string value ("365FZD") to a SQL numeric column.
The order of the elements in the column input should be VarcharColumn and then NumericColumn in the example shown, or have the DBL value in the data cluster as the first element and the string value as the second element.
- If you are sure the data is of the correct type, the problem may be occurring if your data goes out of the valid range. For example, if your date field goes out of range, it returns -/-/- instead of valid values. Your database might have criteria set that only valid dates are acceptable. This might also happen if other values, like numerics, go out of range. In order to avoid this, you must check for out-of-range values in your program before you write them to the database. If a value is not valid, you can assign some default value to write for these out-of-range cases. This helps to preserve database integrity as well.