Click here to Skip to main content
16,018,158 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am getting exception as

Unable to cast object of type 'System.String' to type 'System.Data.DataRow'.
on line

DataRow dr= (DataRow)MySettings.GetCurrencyCode(CurrId_)[0];

Here GetCurrencyCode() returning a datarow;
i wants to preserve the result of this method in dr;

Please provide the solution for this.
Posted
Comments
Raje_ 8-Jul-14 3:35am    
Why are you using [0] ?
DamithSL 8-Jul-14 3:54am    
what is GetCurrencyCode? can you update the question with that method code?

your code is wrong. your code should be :
C#
DataRow dr = (DataRow)MySettings.GetCurrencyCode(CurrId_); 

Now try and check if it works.

Good luck.
 
Share this answer
 
Comments
Raje_ 8-Jul-14 4:10am    
Please make sure to write a comment(reason for downvoting), if any one downvotes the solution. here I see some one has downvoted without writing any proper reoson.This way i will also get to know where i am doing wrong. :(
Hi,

Remove array index [0] from the last of statement. It is giving a string value and you are getting error.

Like,

C#
DataRow dr = (DataRow)MySettings.GetCurrencyCode(CurrId_);
 
Share this answer
 
v2
Comments
Sarvesh Kumar Gupta 8-Jul-14 4:51am    
Please give the reason who has downvoted my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900