Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Error: Specified cast is not valid

Reply
Thread Tools

Error: Specified cast is not valid

 
 
Web Team @ Borough of Poole
Guest
Posts: n/a
 
      04-25-2005
Hi All,


When I run the below code, I get error 'Specified cast is not valid' on
line

163 Dim Address As OldInfra.BS7666.Address =
BS7666AddressCollection.GetSingleAddress(str_UPRN)

164 Dim easting As Integer = Address.Easting
165 Dim northing As Integer = Address.Northing

Address.Northing is an Integer in my class:

Me.Northing = CType(DR("Northing"), Integer)

Any advice anyone?


Thanks,
Simon.

 
Reply With Quote
 
 
 
 
TDAVISJR
Guest
Posts: n/a
 
      04-25-2005
User the debugger to see what kind of object is Me. Northing is OR do a
Response.Write("Me.Northing is of type: " & Me.Northing.GetType())

If you do not get Integer as your output then yeah, that cast will be
incorrect

Also, turn Option Strict on

--
TDAVISJR
aka - Tampa.NET Koder


"Web Team @ Borough of Poole" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi All,
>
>
> When I run the below code, I get error 'Specified cast is not valid' on
> line
>
> 163 Dim Address As OldInfra.BS7666.Address =
> BS7666AddressCollection.GetSingleAddress(str_UPRN)
>
> 164 Dim easting As Integer = Address.Easting
> 165 Dim northing As Integer = Address.Northing
>
> Address.Northing is an Integer in my class:
>
> Me.Northing = CType(DR("Northing"), Integer)
>
> Any advice anyone?
>
>
> Thanks,
> Simon.
>



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      04-25-2005
If Northing is Nothing, that would do it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Web Team @ Borough of Poole" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi All,
>
>
> When I run the below code, I get error 'Specified cast is not valid' on
> line
>
> 163 Dim Address As OldInfra.BS7666.Address =
> BS7666AddressCollection.GetSingleAddress(str_UPRN)
>
> 164 Dim easting As Integer = Address.Easting
> 165 Dim northing As Integer = Address.Northing
>
> Address.Northing is an Integer in my class:
>
> Me.Northing = CType(DR("Northing"), Integer)
>
> Any advice anyone?
>
>
> Thanks,
> Simon.
>



 
Reply With Quote
 
Craig Deelsnyder
Guest
Posts: n/a
 
      04-26-2005
On Mon, 25 Apr 2005 09:01:22 -0500, Web Team @ Borough of Poole
<(E-Mail Removed)> wrote:

> Hi All,
>
>
> When I run the below code, I get error 'Specified cast is not valid' on
> line
>
> 163 Dim Address As OldInfra.BS7666.Address =
> BS7666AddressCollection.GetSingleAddress(str_UPRN)
>
> 164 Dim easting As Integer = Address.Easting
> 165 Dim northing As Integer = Address.Northing
>
> Address.Northing is an Integer in my class:
>
> Me.Northing = CType(DR("Northing"), Integer)
>
> Any advice anyone?
>
>
> Thanks,
> Simon.
>


Make sure DR("Nothing") isn't DBNull? Not sure what DR is, though...

http://www.freevbcode.com/ShowCode.asp?ID=5810


--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
Web Team @ Borough of Poole
Guest
Posts: n/a
 
      04-27-2005
Thanks everyone - Northing was indeed Nothing!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: specified cast is not valid. Why not? Alan Silver ASP .Net 5 02-15-2005 08:08 PM
User Control - InvalidCastException: Specified cast is not valid Ajit ASP .Net 1 04-24-2004 09:28 PM
I get the following error ( Specified cast is not valid ) with Server.Transfer Andrew ASP .Net 0 08-12-2003 08:26 PM
System.InvalidCastException: Specified cast is not valid. Arjen ASP .Net 1 08-06-2003 03:26 AM
System.InvalidCastException: Specified cast is not valid Floela ASP .Net 3 07-10-2003 10:36 AM



Advertisments