Hello Friends,
I m new in C# programming.
when i access data from a file.
i don't know each field has data or not.
but in my c# coding file wirte code
double value=Convert.ToDouble(dataRow["fieldValue"]);
if fieldValue is null or empty this code show exception.
Please suggest.
Thanks.
Loading
Jitendra TiwariPosted Mar 18, 2010, 1:30 AM
where
(listSchemeCode.Contains(abc.Field
|| (listTrnxNo.Contains(Convert.ToString((abc.Field
|| (listFolioNo.Contains((abc.Field
select abc);
there is no prob field value is double or string.
problem is that if the value of TransactionNO(Bold in code block) is null linq query throw exception.
when I access each row from data row collection
Sam HobbsPosted Mar 17, 2010, 3:03 PM
Jitendra TiwariPosted Mar 17, 2010, 9:52 AM
thanks
but my problem like this
excelUserRecord = (from abc in dataRow
where
(listSchemeCode.Contains(abc.Field
|| (listTrnxNo.Contains(Convert.ToString((abc.Field
|| (listFolioNo.Contains((abc.Field
select abc);
if transaction is null form show errorrrr
Amit ChoudharyPosted Mar 17, 2010, 5:13 AM
put a condition before using the value:
if(dataRow["fieldValur"]!=DBnull)
{
double value=Convert.ToDouble(dataRow["fieldValue"]);
}
please mark as answer if it helps.
Hirendra SisodiyaPosted Mar 17, 2010, 4:18 AM
if (dataRow["fieldValue"] != null)
{
double value = Convert.ToDouble(dataRow["fieldValue"]);
}
else
{
}
thanks
Please Check answere if you like my answere