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
LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.