Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
my store procedure is

SQL
ALTER PROCEDURE [dbo].[AttendenceMonthly]
@EmployeeId int
AS

declare @i int
declare @nowdate datetime,@redusedatetime datetime,@redusedate datetime,@newdate datetime,@count int,@affectedrow int
 Declare @p AS NVarchar(4000)
set @nowdate =GETDATE()
set @redusedatetime=DATEADD(DD,-21,@nowdate)
set @redusedate =CONVERT(varchar(10),@redusedatetime,23)
set @p=0

BEGIN
set @i=1
set @count=0
while(@i <= (select datediff(day, GETDATE(), dateadd(month, 1, GETDATE()))))
begin
select * from TblAttendence where convert(varchar(10),LoginTime,23) = @redusedate and EmployeeId =@EmployeeId
if @@ROWCOUNT = 1
begin
    set @count =@count +1
end
set @redusedate=DATEADD(DD,+1,@redusedate)
set @redusedate=CONVERT(varchar(10),@redusedate,23)
set @i=@i+1
end
select @count

END





i want only count value in my project
Posted
Updated 22-Apr-14 5:36am
v2
Comments
Okay, so where is the problem?

1 solution

public static int AttendenceMonthly(int employeeId)
{
int AttendenceMonthly = -1;

SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
SqlCommand cmd = new SqlCommand("AttendenceMonthly", conn);

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@EmployeeId", employeeId);

try

{
conn.Open();
order_id = Int32.Parse(cmd.ExecuteScalar().ToString());
return order_id;

}
catch (SqlException se)

{
System.Console.WriteLine(se.Message);

}

conn.Close();
return AttendenceMonthly;
}
 
Share this answer
 
Comments
Pleas don't add codes like this without knowing what is the issue. OP has only provided the Stored Procedure, but did not describe the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900