我在我的SQL查詢中使用了一個計算。我如何在C#中使用該計算字段?當我嘗試時,我得到一個索引超出範圍的例外。使用C#中的查詢時,索引超出範圍例外
我的查詢是:
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
我想在我的C#代碼使用inlt_percent * inlt_effectinterest)/100
:
entity.ParentCompany = new List<Company>();
while (parentCompanyReader.Read())
{
ParentCompany.Effect = parentCompanyReader["eff"].ToString();
entity.ParentCompany.Add(ParentCompany);
}
parentCompanyReader.Close();
但我得到上述錯誤。
它不是一個sql錯誤.. problwm似乎是在你的C#數組'parentCompanyReader',...你需要發佈你的C#代碼在這裏 – Kshitij