Hi
I need to display value/data from stored procedure into text box in asp.net.
I have used below code from this forum. But not returned value in textbox
IF @Action = 'WEEKLY-REVENUE'
BEGIN
SELECT sum(subtotal) FROM [dbo].[tbl_Finance]
where YEARNO = '2021' AND Weekno = '5'
GROUP BY YEARNO,WeekNo
END
in asp.net web page
Private Sub WeeklyRevenue()
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand("usp_W_Finance")
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@Action", "WEEKLY-REVENUE")
cmd.Connection = con
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Read()
Me.lblWeeklyRevenue.Text = sdr("subtotal").ToString()
End Using
con.Close()
End Using
End Using
End Sub
This is table structure with data
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tbl_Finance](
[DocDate] [date] NULL,
[Category] [varchar](30) NULL,
[Type] [varchar](30) NULL,
[SubTotal] [numeric](18, 2) NULL,
[Gross] [numeric](18, 2) NULL,
[Tax] [numeric](18, 2) NULL,
[NettTotal] [numeric](18, 2) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'PROPERTY', N'FLAT RATE', CAST(21250.00 AS Numeric(18, 2)), CAST(25000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(21250.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'PROPERTY', N'FLAT RATE', CAST(14250.00 AS Numeric(18, 2)), CAST(14250.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(14250.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'HEALTH', N'FLAT RATE', CAST(60000.00 AS Numeric(18, 2)), CAST(60000.00 AS Numeric(18, 2)), CAST(3600.00 AS Numeric(18, 2)), CAST(63600.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'BANK', N'RATE-36', CAST(11325.40 AS Numeric(18, 2)), CAST(13324.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(11325.40 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'SEMINAR', N'RATE-46', CAST(2815.20 AS Numeric(18, 2)), CAST(3312.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(2815.20 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'PROPERTY', N'FLAT RATE', CAST(1011.50 AS Numeric(18, 2)), CAST(1190.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(1011.50 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'SERVICE', N'FLAT RATE', CAST(150000.00 AS Numeric(18, 2)), CAST(150000.00 AS Numeric(18, 2)), CAST(9000.00 AS Numeric(18, 2)), CAST(159000.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-27' AS Date), N'EDUCATION', N'FLAT RATE', CAST(5000.00 AS Numeric(18, 2)), CAST(5000.00 AS Numeric(18, 2)), CAST(300.00 AS Numeric(18, 2)), CAST(5300.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-20' AS Date), N'SERVICE', N'FLAT RATE', CAST(5100.00 AS Numeric(18, 2)), CAST(6000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(5100.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-20' AS Date), N'FURNITURES', N'FLAT RATE', CAST(10200.00 AS Numeric(18, 2)), CAST(12000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(10200.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-20' AS Date), N'PROPERTY', N'FLAT RATE', CAST(5698.40 AS Numeric(18, 2)), CAST(6704.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(5698.40 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-20' AS Date), N'FURNITURES', N'FLAT RATE', CAST(34850.00 AS Numeric(18, 2)), CAST(41000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(34850.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-19' AS Date), N'FURNITURES', N'FLAT RATE', CAST(32130.00 AS Numeric(18, 2)), CAST(37800.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(32130.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-19' AS Date), N'CONGRATS', N'FLAT RATE', CAST(68000.00 AS Numeric(18, 2)), CAST(80000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(68000.00 AS Numeric(18, 2)))
INSERT [dbo].[tbl_Finance] ([DocDate], [Category], [Type], [SubTotal], [Gross], [Tax], [NettTotal]) VALUES (CAST(N'2021-01-19' AS Date), N'BANK', N'FLAT RATE', CAST(26350.00 AS Numeric(18, 2)), CAST(31000.00 AS Numeric(18, 2)), CAST(0.00 AS Numeric(18, 2)), CAST(26350.00 AS Numeric(18, 2)))
GO
Yearno = (datepart(year,[docdate]))
WeekNo = (datepart(week,[docdate]))
Pls advice me
Thank you
Maideen