I have a store procedure like following
CREATE procedure [dbo].[Sp_GetLedger]
AS
BEGIN
SELECT *,SUM(isnull(HomeCurrencyDR,0) - isnull(HomeCurrencyCR,0)) OVER (ORDER BY Voucher_No ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as Balancee
FROM ViewTransectionLedger
order by Voucher_date
END
I have shown it in grid view. But I have to know how I can set parameters from the input side for data filtering in c#
Ajay SinghPosted Dec 25, 2022, 4:54 PM
Hi Sanjeev, Please have look at below very simple example for store procedure using input params. You can modify your procedure similar to this.
In Below procedure @BrandName is input param for a procedure. Hence you have to pass this param as an input where you are executing your store procedure.
CREATE PROCEDURE uspSelectAllCarsByBrandName
(
@BrandName varchar(20)
)
AS
BEGIN
Select * FROM dbo.Cars
WHERE BrandName = @BrandName
END
Run the procedure - Exec uspSelectAllCarsByBrandName 'KIA'
Jignesh KumarPosted Dec 25, 2022, 8:40 AM
Hi Sanjeev,
Please refer this thread which will help you to understand parameterized store procedure,
https://www.c-sharpcorner.com/article/filter-records-based-on/
https://www.aspsnippets.com/questions/117984/Filter-ASPNet-GridView-using-Store-Procedure-in-C-and-VBNet/