大家好,当我在asp.net上调用存储过程时,我收到此错误 -
过程或函数'uspTargetQuantites'需要参数 “@Product”,未提供。
我的存储过程...
USE [WorkstationCells]
GO
/****** Object: StoredProcedure [dbo].[uspTargetQuantites] Script Date: 11/04/2018 08:27:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[uspTargetQuantites] (@Product VARCHAR(10))
AS
SET NOCOUNT ON
/* debug */
--DECLARE @Product VARCHAR(10)
--SET @Product = 'G120C'
/* debug */
SELECT Product
, Framesize
, HourName
, Quantity
INTO #PivotData
FROM WorkstationCells.dbo.TargetQuantites
WHERE Product = @Product
SELECT DISTINCT Framesize INTO #PivotDataProducts FROM #PivotData
DECLARE @PivotColumnHeaders VARCHAR(MAX)
SELECT @PivotColumnHeaders =
COALESCE(
@PivotColumnHeaders + ',[' + cast(Framesize as varchar) + ']',
'[' + cast(Framesize as varchar)+ ']'
)
FROM #PivotDataProducts
DECLARE @PivotTableSQL NVARCHAR(MAX)
SET @PivotTableSQL = N'
SELECT * FROM #PivotData AS PivotData
PIVOT (SUM(Quantity)FOR Framesize IN (' + @PivotColumnHeaders + ')) AS PivotTable
'
EXECUTE(@PivotTableSQL)
DROP TABLE #PivotData
DROP TABLE #PivotDataProducts
--EXEC uspTargetQuantites 'G120C'
谁能告诉我哪里出错了??
这是我的c#代码...来调用SP
public void Refreshdata()
{
SqlConnection con = new SqlConnection(@"Server=(LocalDB)\v11.0;Database=WorkstationCells");
SqlCommand cmd = new SqlCommand("[dbo].[uspTargetQuantites]", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}