Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting integer from dataset without tostring conversion
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00705358
Message ID:
00705467
Views:
14
Using this approach works for me without any runtime error. Is the receiving object of type int? Are you sure the fk_dept can be converted to int? Did something get confused in the translation of the XML string? Just some ideas.

>I get the follow error at runtime "System.InvalidCastException: Specified cast is not valid."
>Any ideas?
>
>Having to cast the fields seems strange to start with. This dataset was created from an XML string passed, and this included the types.
>
>>You need to cast the DataRow value to an int like the following:
>>
>>
>>(int)dsClinserv.Tables["cresult"].Rows[0]["fk_dept"];
>>
>>
>>>How can I get an interger value out of a dataset without converting to a string and then back to an integer? I am using the following (very rundundant) code. There must be a better way.
>>>
>>>
>>>Convert.ToInt16(dsClinserv.Tables["cresult"].Rows[0]["fk_dept"].ToString())
>>>
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform