ALTER Procedure [dbo].[HRptForm3A]
@StrCond Varchar(1000),
@SelYear int,
@Type varchar(1)
as
Declare @Tbl varchar(30)
if ( @Type = 'O')
begin
set @Tbl = 'TblResult'
end
else if( @Type = 'I')
begin
set @Tbl = 'TblGResult'
end
Declare @FromPayPeriodId Int
Declare @ToPayPeriodId Int
select @FromPayPeriodId=isnull(Min(PayPeriodId),0),@ToPayPeriodId=isnull(Max(PayPeriodId),0) from tblPayPeriodMst Where
Month(FromDate) in (4,5,6,7,8,9,10,11,12) and Year(FromDate)=@SelYear or
Month(FromDate) in (1,2,3)and Year(FromDate)=@SelYear+1
Declare @Qry2 Varchar(1000)
Set @Qry2='Select E.Empid,E.Empcode,E.Empname,E.EmpFhName,E.Condate,E.PfNo as AccountNo,E.VPF,E.Leftdate,E.ReasonForLeft,R.payperiodId,
R.Lop,R.LWF,R.PFGross,R.PF,R.EPFE,R.EPFR, **Month(P.FromDate)+1** as Monthnumber ,Year(P.FromDate) as YearNumber,
Case
When Month(P.FromDate) in(4,5,6,7,8,9,10,11,12) then Month(P.FromDate)
when Month(P.FromDate) in(1,2,3) then Month(P.FromDate)
end as Mnth
From
PayEmpMstView as E,' + @Tbl + ' as R,tblPayPeriodMst as P
where E.Empid=R.Empid and len(E.PFNo)>0
and R.PayPeriodId=P.PayPeriodid and
P.PayPeriodid between ' + Convert(Varchar(10),@FromPayPeriodId) + ' and '+ Convert(Varchar(10),@ToPayPeriodId)+ @StrCond +
' Order by E.EmpCode,Year(P.FromDate),Month(P.ToDate)'
Exec(@Qry2)
Exec ('Select E.EmpCode,E.EmpId from tblPayEmployee E Where 0=0 ' + @StrCond )
GO
when i change the highlighted value Month(P.FromDate) to Month(P.FromDate)+1. its showing exception error in the coding part of vb.net as HRESULT:800340 error this change is working in sql server 2000 but not in 2005. how to overcome this
Karthik added this code in the comments. It appears to be VB.NET code. It's not super legible.
MNth(4) = "Apr-" & Year :
MNth(5) = "May-" & Year.ToString :
MNth(6) = "Jun-" & Year.ToString :
MNth(7) = "Jul-" & Year.ToString
MNth(8) = "Aug-" & Year :
MNth(9) = "Sep-" & Year.ToString :
MNth(10) = "Oct-" & Year.ToString :
MNth(11) = "Nov-" & Year.ToString
MNth(0) = "Dec-" & Year :
MNth(1) = "Jan-" & (Year + 1).ToString :
MNth(2) = "Feb-" & (Year + 1).ToString :
MNth(3) = "Mar-" & (Year + 1).ToString
Dim J As Integer J = 4 ' k = 1
IdOfEmp = Val(DS.Tables(0).Rows(TotalCnt).Item("EmpId"))
While J < 13
Try
While IdOfEmp = Val(DS.Tables(0).Rows(TotalCnt).Item("EmpId"))
If J = Val(DS.Tables(0).Rows(TotalCnt).Item("MonthNumber"))
Then .PrintString(" | | | | | | | | |") :
.NewLine() :
.Tab(.LeftMargin)
If J = 12
Then J = 0
End If
.PrintString(MNth(J), 9, DosPrint.Align.Left)
I'm not sure that the best approaches are being followed here, but ... I'm just trying to clean things up.