Index out of range exception when using this query from C#
- by jenifa
I am using a calculation in my SQL query. How can I use that calculated field in C#? When I try, I get an index out of range exception.
My query is:
Select OwnerCompanyLog.olog_name,inlt_companyid,inlt_childcompid,inlt_effectinterest,inlt_percent,inlt_sharetype,inlt_shares,inlt_childbase,inlt_effdate,
(inlt_percent * inlt_effectinterest)/100)eff
from InterestLogTable
INNER JOIN OwnerCompanyLog
ON
InterestLogTable.inlt_childcompid = OwnerCompanyLog.olog_companyid
where inlt_companyid=5
Order By inlt_childcompid
I want to use inlt_percent * inlt_effectinterest)/100 in my C# code:
entity.ParentCompany = new List<Company>();
while (parentCompanyReader.Read())
{
ParentCompany.Effect = parentCompanyReader["eff"].ToString();
entity.ParentCompany.Add(ParentCompany);
}
parentCompanyReader.Close();
But I got the error above.