Error -2147217900 When Executing a SQL Stored Procedure in LabVIEW

Updated Sep 5, 2024

Reported In

Software

  • LabVIEW
  • Database Connectivity Toolkit

Issue Details

  • When I call a stored procedure from LabVIEW using the Database Connectivity Toolkit, I am getting this error:
Error -2147217900 occurred at NI_Database_API.lvlib:Cmd Execute.vi->callProc.vi->main.vi

Possible reason(s):
ADO Error: 0x80040E14
Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Oracle][ODBC][Ora]ORA-00900: invalid SQL statement
 in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->callProc.vi->main.vi

 
  • I am trying to insert a string with a length greater than 8000 characters to a SQL server with the LabVIEW Database Connectivity Tool, using a stored procedure, however, I get the following error in LabVIEW:
 
Error -2147217900 occurred at NI_Database_API.lvlib:Cmd Execute vi:

Possible reason(s):

ADO Error: 0x80040E14

Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function '<procedure name>' expects parameter '<parameter name>', which was not supplied. in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi
 
image.png

 

Solution

This error can be produced due to various reasons, including an incorrect syntax or a truncation problem happening due to an underlying issue with the driver or provider being used to connect to the database.
 
  • If you encounter this error when trying to write a long string, verify if the table field is set to a type that allows that length, for example varchar(max) data type allows for strings longer than 8000 bytes. Try manually creating a query in Microsoft SQL Server Management Studio to insert a string into the same table, if there's no error and the string is correctly inserted into the table the issue might be related to the driver or provider being used in LabVIEW. For example, when using the following connection string you can see this error when calling a stored procedure to insert a string of more than 8000 characters:
Driver=SQL Server; Server=ServerName; Database=DatabaseName; Trusted_Connection=True;

You can use the Microsoft OLE DB Provider for SQL Server instead to avoid this. The following connection string can be use when connecting to the database to avoid the error:
 
Provider=MSOLEDBSQL; Server=ServerName; Database=DatabaseName; Trusted_Connection=yes;

 

Additional Information

The error message can mention a missing parameter in the stored procedure, even though there is no missing one in the SQL query created in LabVIEW, this can be due to a truncation in the query and not necessarily a missing parameter. In similar circumstances, inserting a string longer than 8000 characters with a regular query instead of using a stored procedure, can produce error -2147217833 indicating a truncation in the data.