Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 498
  • Last Modified:

reader smallint casting

I am trying to do this:

        Dim level As Integer = reader.GetInt32(4)

I keep getting an error that I cannot cast that .....
The value in reader (4) is a small int.

What do I use to get the small int and what do I cast it to?

thanks
0
Starr Duskk
Asked:
Starr Duskk
  • 2
1 Solution
 
McExpCommented:
This should work for you:-
Dim level As Integer = reader.GetInt16(4)

Open in new window

0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
that worked....

But so did the GetValue(4) that I tried just prior.

Which should I use, and why?
thanks!
0
 
McExpCommented:
using GetValue returns an object you will have to cast to an int16.
using GetInt16 returns an int16 you will not have to cast.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now