LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview and SQL stored procedure - Procedure or function StoreTemp has too many arguments specified

I have a stored procedure looking like this:

 

CREATE PROCEDURE [dbo].[StoreTemp]
(@Temperature float,
@Seconds int,
@SessionId int)
AS
BEGIN
DECLARE @Unit varchar(20);

SELECT @Unit = RecordingUnit FROM ReadLastUnit;

INSERT INTO DATASET (Temperature_C, Temperature_F, Seconds, SessionId, [Time])
SELECT
CASE WHEN @Unit = 'Celsius' THEN @Temperature ELSE NULL END,
CASE WHEN @Unit != 'Celsius' THEN @Temperature ELSE NULL END,
@Seconds, @SessionId, GETDATE();
END

 

In labview I prepare the string with parameters like

execute StoreTemp %2.1f, %d, %d

which takes 3 parameters which are input through a "Format into string" box.

The following error is thrown:

 

> Error -2147217900 occurred at Exception occurred in Microsoft OLE DB Provider for ODBC Drivers:
> [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function StoreTemp has too many arguments specified. in ADODBCommand

 

The above SQL Server stored procedure should basically get the one measurement value `@Temperature` from LabView, and depending on the recording settings (- which is read as @Unit from ReadLastUnit View) either store the temperature in one unit and fill the other unit column with null, and vice versa. Somehow it seems to be getting more parameters, although 3 inputs are specified and 3 parameters are passed through LabView. What does this error mean then?

image.png

0 Kudos
Message 1 of 3
(2,081 Views)

Hi SeeSharpDev,

 

I think you need some more syntax around the command you are trying to execute.  If you copy and paste the 'resulting string' value into SQL Server Management Studio and try to run it from there, it won't work as it is.

 

Try 'execute StoreTemp @Temperature=%2.1f, @Seconds=%d, @SessionID=%d' instead

 

Cheers

Brett

Senior Software Development Engineer
Certified LabVIEW Architect and LabVIEW Champion
https://theLonelyAnt.com
https://GDevConANZ.org.au


0 Kudos
Message 2 of 3
(2,033 Views)

"%2.1f" could convert a float to a number containing a ",".

 

~50% of the computers are set to use commas as decimal separator.

 

This might not be the case, but you should always use "%.;%2.1f" anyway...

Message 3 of 3
(2,024 Views)