pedrodotnet
pedrodotnet

Reputation: 818

C# Assign Value from Dynamic Data Reader to variable

I have a count query on my program which result is assigned to a Dynamic Data Reader variable. I need to assign the result of that count to an int variable. While debbuging I can see that the count result is there as can be seen below, the result is 3142:

enter image description here

The problem here is that I not being able to assign that value from the Dynamic to an int variable. Any ideas?

I'm trying the following way:

dynamic dreader = new DynamicDataReader(rawReader);
                var count = (int)dreader["Value"];

the rawReader is the result of the Query executed

Upvotes: 0

Views: 282

Answers (1)

TimB
TimB

Reputation: 1000

Try Integer.Parse() instead - or Integer.TryParse() if you want to find out whether the value can be transformed to int at all.

Upvotes: 0

Related Questions