• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 499
  • 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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

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