你好下面是我在 C# 中的代码
var a =
from c in HRM_dc.uspCalculateRiskMatrix(CashPrice, InputAPH, Bushels, PercentageCover, BasicEstimate, CallStrike, CallBu, CallPremium,PutStrike, PutBu, PutPremium, TotalAcres, AvgPrice, PerAcreProductionCost, SpringPrice)
select new
{
bushels = c.Bushel,
row1 = c._0_00.Value
};
gvRisk.DataSource = a;
gvRisk.DataBind();
请帮助我为什么会发生此错误
存储过程
ALTER PROC [dbo].[uspCalculateRiskMatrix]
@CashPrice MONEY, @InputAPH INT, @Bushels INT, @PercentageCover FLOAT, @BasicEstimate FLOAT,
@CallStrike FLOAT, @CallBu INT,
@CallPremium FLOAT, @PutStrike FLOAT, @PutBu INT, @PutPremium FLOAT, @TotalAcres FLOAT, @AvgPrice
MONEY, @PerAcreProductionCost MONEY,
@SpringPrice MONEY
AS
BEGIN
SET NOCOUNT ON
DECLARE @BushelInterval INT, @BushelRange INT, @BushelValueCounter INT
DECLARE @PriceInterval FLOAT, @PriceRange INT, @PriceValueCounter FLOAT
DECLARE @CurrRow INT
IF 1 = 2
BEGIN
SELECT NULL AS Bushel, NULL AS [0.00], NULL AS [1.00], NULL AS [2.00], NULL AS [3.00], NULL AS [4.00]
,NULL AS [5.00], NULL AS [6.00], NULL AS [7.00], NULL AS [8.00], NULL AS [9.00], NULL AS [10.00]
END
CREATE TABLE #tblTemp (Bushel VARCHAR(30), [0.00] FLOAT, [1.00] FLOAT, [2.00] FLOAT, [3.00] FLOAT,
[4.00] FLOAT
, [5.00] FLOAT, [6.00] FLOAT, [7.00] FLOAT, [8.00] FLOAT, [9.00] FLOAT, [10.00] FLOAT)
SET @BushelInterval = 10
SET @BushelRange = 5
SET @BushelValueCounter = 0
SET @PriceInterval = 0.15
SET @PriceRange = 5
SET @PriceValueCounter = 0
SET @CurrRow = 1
DECLARE @tblBushelRow TABLE (ID INT IDENTITY(1,1), BushelValue INT)
DECLARE @tblPriceCol TABLE (ID INT IDENTITY(1,1), CashPrice MONEY)
CREATE TABLE #tblMatrix (ID INT IDENTITY(1,1), Bushel VARCHAR(30), CashPrice MONEY, CalValue FLOAT)
INSERT INTO @tblBushelRow (BushelValue) VALUES(@Bushels)
WHILE @CurrRow <= @BushelRange
BEGIN
SET @BushelValueCounter = @BushelValueCounter + @BushelInterval
INSERT INTO @tblBushelRow (BushelValue) VALUES(@Bushels + @BushelValueCounter)
INSERT INTO @tblBushelRow (BushelValue) VALUES(@Bushels - @BushelValueCounter)
SET @CurrRow = @CurrRow + 1
END
SET @CurrRow = 1
INSERT INTO @tblPriceCol (CashPrice) VALUES(@CashPrice)
WHILE @CurrRow <= @PriceRange
BEGIN
SET @PriceValueCounter = @PriceValueCounter + @PriceInterval
INSERT INTO @tblPriceCol (CashPrice) VALUES(@CashPrice + @PriceValueCounter)
INSERT INTO @tblPriceCol (CashPrice) VALUES(@CashPrice - @PriceValueCounter)
SET @CurrRow = @CurrRow + 1
END
INSERT INTO #tblMatrix (Bushel, CashPrice)
SELECT T1.BushelValue, T2.CashPrice FROM @tblBushelRow T1 CROSS JOIN @tblPriceCol T2 ORDER BY
T1.BushelValue DESC, T2.CashPrice ASC
--SELECT * FROM #tblMatrix
UPDATE #tblMatrix SET CalValue = dbo.udfGetCornMatrixValue(CashPrice, @InputAPH, Bushel,
@PercentageCover, @BasicEstimate, @CallStrike, @CallBu, @CallPremium,
@PutStrike, @PutBu, @PutPremium, @TotalAcres, @AvgPrice, @PerAcreProductionCost, @SpringPrice)
DECLARE @cols NVARCHAR(MAX), @query NVARCHAR(4000)
SELECT @cols = (SELECT STUFF((SELECT DISTINCT ', '+QUOTENAME(CashPrice) FROM #tblMatrix FOR XML PATH
('')),1,1,''))
--print @cols
SET @query = N'SELECT DISTINCT ''Bushel'', '+@cols +'FROM(SELECT Bushel, CashPrice FROM #tblMatrix) p
PIVOT(SUM(CashPrice) FOR CashPrice IN( '+@cols +' )) AS pvt;'
INSERT INTO #tblTemp(Bushel, [0.00], [1.00], [2.00], [3.00], [4.00], [5.00], [6.00], [7.00], [8.00], [9.00], [10.00])
EXECUTE(@query)
SET @query = N'SELECT Bushel, '+@cols +'FROM(SELECT CAST(Bushel AS VARCHAR) AS Bushel, CashPrice, CalValue FROM #tblMatrix) p
PIVOT(SUM(CalValue) FOR CashPrice IN( '+@cols +' )) AS pvt;'
INSERT INTO #tblTemp(Bushel, [0.00], [1.00], [2.00], [3.00], [4.00], [5.00], [6.00], [7.00], [8.00], [9.00], [10.00])
EXECUTE(@query)
SELECT Bushel, [0.00], [1.00], [2.00], [3.00], [4.00], [5.00], [6.00], [7.00], [8.00], [9.00], [10.00] FROM #tblTemp
DROP TABLE #tblMatrix, #tblTemp