04-17-2020 02:24 AM - edited 04-17-2020 02:26 AM
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?
04-20-2020 11:30 PM
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
04-21-2020 02:38 AM
"%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...