RE: Specified cast is not valid
- From: Sameeksha <Sameeksha@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 18 Aug 2005 04:46:05 -0700
The GetInt16() function returns 'short' which is a C# datatype whereas Int16
is a .net framework's common data type. Although the sizes of both data types
may be the same they are considered as different data types since C# supports
strong type checking.
--
Thanks,
Sameeksha
MCAD.Net
"simon" wrote:
> I declare variable as int16:
>
> int16 hourS;
>
> then I open dataReader and set the variable:
>
> hourS=rdr.getInt16(1);
>
> but I get an error when I start the page:
>
> "Specified cast is not valid."
>
> I don't understand why?
> Both sides are defined as int16, also the value which reader returns is
> small, like 5 for example.
>
> I know, I can use convert function:
>
> hourS=convert.Toint16(rdr.getInt16(1));
>
> it works, but doesn't make sense.
>
> Regards,S
>
>
>
.
- Follow-Ups:
- RE: Specified cast is not valid
- From: Jon Skeet [C# MVP]
- Re: Specified cast is not valid
- From: Bjorn Abelli
- Re: Specified cast is not valid
- From: simon
- RE: Specified cast is not valid
- References:
- Specified cast is not valid
- From: simon
- Specified cast is not valid
- Prev by Date: RE: Propagating events
- Next by Date: Re: 'Roles' does not contain a definition for 'RoleExists'
- Previous by thread: Specified cast is not valid
- Next by thread: Re: Specified cast is not valid
- Index(es):
Relevant Pages
|