Error With SQL Procedures Expecting Boolean or Bit Parameter When Using Database Connectivity Toolkit

Updated Jul 11, 2023

Reported In

Software

  • LabVIEW
  • Database Connectivity Toolkit

Issue Details

I'm trying to communicate with my SQL database using the LabVIEW Database Connectivity Toolkit, which is included with LabVIEW Professional, but I am seeing the below error when attempting to execute SQL stored procedures that expect a boolean or bit as a parameter.

Error generated by trying to execute a SQL procedure expecting a boolean or bit value.

I am using DB Tools Create Parameterized Query to execute the SQL procedures. Is there any factor in LabVIEW that could be causing the issues I'm seeing?

Solution

The behavior you're seeing could be the result of a change that was made in a Database Connectivity Toolkit support VI, DB Tools Type and Dir to ADO.vi, related to typecasting for binary values from LabVIEW datatypes to ActiveX Data Objects (ADOs). In older versions of the Database Connectivity Toolkit, binary values were typecast to the ADO type "adBinary," while in newer versions of the toolkit they are typecase to the ADO type "adLongVarBinary," as shown below.

Screenshot showing modern typecasting of binary values in DBC Toolkit.

You can resolve this error by changing the typecast enumeration in the "Binary" case of DB Tools Type and Dir to ADO.vi from "adLongVarBinary" to "adBinary." DB Tools Type and Dir to ADO.vi is located at the following location: C:\Program Files (x86)\National Instruments\<Your LabVIEW Version>\vi.lib\addons\database\Auxilliary.llb\DB Tools Type and Dir to ADO.vi.

Additional Information

The change to the binary typecast in DB Tools Type and Dir to ADO.vi was made as the result of a different error which is generated when trying to write binary blobs larger than 8000 bytes using the Database Connectivity Toolkit. If you're seeing the error listed in this article and are also writing a blob larger than 8000 bytes, you'll likely need to break up the data you're writing to avoid errors.