How to set default value 0 in compute function.
I am fetching Arrears from the database. I want to set default value 0 for the following statement In case of Arrears are null
int Arr = Convert.ToInt32(dtfinal.Compute("sum(Arrears)", ""));
how to do it???
code is
int Fee = Convert.ToInt32(dtfinal.Compute("sum(Fees)", ""));
int Other = Convert.ToInt32(dtfinal.Compute("sum(Others)", ""));
int Reci = Convert.ToInt32(dtfinal.Compute("sum(Recievable)", ""));
//int Arr = Convert.ToInt32(dtfinal.Compute("sum(Arrears)", ""));
int Net = Convert.ToInt32(dtfinal.Compute("sum(NetBal)", ""));
i am displaying data in datagridview by using the following code
con = new SqlDbConnect();
con.SqlQuery(@"select SPic,fg.Year,fg.Month,IssueDate,DueDate,ParentID,FName,FPhone,fg.AdmissionNo,SName,ClassName,SectionName,Fees,sum(Price) 'Others',ISNULL(Fees,0) + ISNULL(sum(Price),0) 'Recievable',RemBal 'Arrears'
,isnull(( ISNULL(Fees,0) + ISNULL(sum(Price),0)),0) + isnull((RemBal),0) 'NetBal'
from tblFeesGenerate as fg left join tblFeesCollection as fc on fg.AdmissionNo=fc.AdmissionNo inner join tblStdReg as sr on fg.AdmissionNo=sr.AdmissionNo
inner join tblDefClass as dc on fg.ClassID=dc.ClassID inner join tblDefSection as ds on fg.SectionID=ds.SectionID
where fc.AdmissionNo is null or fc.AdmissionNo is not null and
fg.Year = @Year and fg.Month=@Month and fg.YearID=@YId and
fc.AdmissionNo not IN(SELECT AdmissionNo FROM tblFeesCollection WHERE FeesMonth = @Month AND Paid >= 0 )
and FeeID IN (SELECT MAX(FeeID) FROM tblFeesCollection group by AdmissionNo)
Group by SPic,ParentID,fg.AdmissionNo,fg.Month,RemBal,SName,FName,fg.Year,fg.ClassID,ClassName,fg.SectionID,SectionName,FPhone,Fees,IssueDate,DueDate order by ParentID desc;");
con.Cmd.Parameters.Add(new SqlParameter("@Year", this.cmbPYear.SelectedItem.ToString()));
con.Cmd.Parameters.Add(new SqlParameter("@Month", this.cmbMonth.SelectedItem.ToString()));
con.Cmd.Parameters.Add(new SqlParameter("@YId", this.cmbYear.SelectedValue.ToString()));