Saturday, March 31, 2012

System.InvalidCastException:

I get a System.InvalidCastException on the following code.

ObjtInterestLadder.dblPrinCcyAmt = (double) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"];

Why is this.

When I retrieve the data to a string it is OK

sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();

have you checked for NULL values?


franklb wrote:

Why is this.

When I retrieve the data to a string it is OK

sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();


What is it showing when you do that ? If it is null or blank it will show exception.

0 comments:

Post a Comment