Solved

reader smallint casting

Posted on 2007-11-19
3
492 Views
Last Modified: 2008-02-07
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
Comment
Question by:Starr Duskk
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
McExp earned 500 total points
ID: 20316558
This should work for you:-
Dim level As Integer = reader.GetInt16(4)

Open in new window

0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20316671
that worked....

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

Which should I use, and why?
thanks!
0
 
LVL 16

Expert Comment

by:McExp
ID: 20321594
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question