Hi Danil,
Your select statement is incorrect.
SELECT SUM(kWDiff), SUM(kVADiff) from dbo.Socket_Final_Insert_Meter_Detail
where ((datepart(MM, Reading_Date)=@month
and datepart(YYYY, Reading_Date)=@year)
and (datepart(HH, Reading_Date) between 22 and 06)
and Meter_Number=@meterid
AND (datepart(HH, Reading_Date) IS NULL))
In the above query you are checking HH of Reading_Date with And condition two time first with between (22 and 06) and then you are checking same with is null. And both condition can not be true at the same time. And hence you are not getting any result.
Execute this query in sql server and with appropriate value and check if you are getting any resule.
Also modify C# code snippet as below.
if(rdr.HasRow)
{
while (rdr.Read())
{
invoice.KW_offpeak = rdr.GetDouble(0);
invoice.KVA_offpeak = rdr.GetDouble(1);
}
}
Hope this will help you.