Reputation: 969
If i do this sql query below I get the single value 26
SELECT Count(*)
FROM [sqlPractice].[dbo].[vcVisitors]
But when i use the below stored procedure it has 2 results - the number I am after and then a return value which is '0'. How do i get the other value and input it into a label?
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [dbo].[UP_SEL_Count]
(
@expectedDate as datetime
)
AS
BEGIN
SELECT Count(*)
FROM [sqlPractice].[dbo].[vcVisitors]
Where expectedDate = @expectedDate and cancelled = 0
END
GO
The code i use to inout the number into a label is below - but all it does is show the return value (0) - how do i get the value i want?
int total_visits = Convert.ToInt32(cmd.ExecuteScalar());
lblTotal_vis_today.Text = total_visits.ToString();
Upvotes: 0
Views: 775
Reputation: 969
The date value being sent to @expectedDate wasn't correct so I wasn't getting the values I needed back. All fixed now - thanks for your help!
Upvotes: 0
Reputation: 1289
Here is an article on how to return values from a stored procedure: http://technet.microsoft.com/en-us/library/ms188655.aspx
Upvotes: 1