Some Type Conversion Errors+Sourabh Das
Hi,
I am getting some unusual simple errors.
Not good in C#. Please Specify the corrections.
Regards,
Code:
DateTime CAP_DATE = dsSet.Tables["VW_ASSETLIST2"].Rows[i]["CAP_DATE"];
Error: Cannot implicitly convert type 'object' to 'System.DateTime'. An explicit conversion exists (are you missing a cast?)
Code:
double CAP_AMT = dsSet.Tables["VW_ASSETLIST2"].Rows[i]["CAP_AMT"];
Error: Cannot implicitly convert type 'object' to 'double'. An explicit conversion exists (are you missing a cast?)
Regards.
Re: Some Type Conversion Errors+Sourabh Das
The error message is telling you the exact problem.
dsSet.Tables["VW_ASSETLIST2"].Rows[i]["CAP_AMT"] returns an object type and you are trying to convert it implicitly to a double. You need to explicitly do the conversion, by either casting it or using the Parse method to convert the data. This error message is a result of C# being a strongly typed language. In VB.Net you could get away with this if you have Option Strict Off (which I rarely recommend).