尝试使用Int参数运行SQL Server存储过程时出现Excel VBA溢出错误

我有一个OrderID 32777在Excel中声明为数据types。 我试图通过下面的代码行传递给存储过程:

RunStoredProcedure "dbo.updateinventory", CLng(OrderID), "Orderid" 

当我尝试时出现以下错误,尽pipe包括CLng函数。debugging器突出显示的行是上面的那个:

在这里输入图像说明

原始的存储过程如下所示。

 @OrderId Int as Begin update P Set P.Available = P.Available - Q.QuantityOrdered, From Products P join (Select ProductID, sum(Quantity) from OrderDetails where OrderID = @OrderId Group By ProductId) Q on P.ID = Q.ProductID End 

我已经尝试在存储过程中将@Orderidvariables的数据types更改为BigInt,但仍然出现错误。

编辑:我已经将orderdetails表中的OrderID列的数据types从int更改为bigint,但仍然得到错误。

任何人都可以协助吗?

干杯

我刚刚发现问题! 它在数据到达数据库之前在VBA代码中。 该值被转换回一个int! 卫生署

谢谢你的回复!