Error: Specified cast is not valid

Discussion in 'ASP .Net' started by Web Team @ Borough of Poole, Apr 25, 2005.

  1. 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.
     
    Web Team @ Borough of Poole, Apr 25, 2005
    #1
    1. Advertising

  2. Web Team @ Borough of Poole

    TDAVISJR Guest

    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" <> wrote in message
    news:...
    > 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.
    >
     
    TDAVISJR, Apr 25, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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.
    >
     
    Kevin Spencer, Apr 25, 2005
    #3
  4. On Mon, 25 Apr 2005 09:01:22 -0500, Web Team @ Borough of Poole
    <> 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
     
    Craig Deelsnyder, Apr 26, 2005
    #4
  5. Thanks everyone - Northing was indeed Nothing! :)
     
    Web Team @ Borough of Poole, Apr 27, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew
    Replies:
    0
    Views:
    679
    Andrew
    Aug 12, 2003
  2. Stefan Landgraf

    Re: 'Specified Cast Is Not Valid' Error!

    Stefan Landgraf, Aug 19, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    429
    Stefan Landgraf
    Aug 19, 2003
  3. Miguel Angel Dinelli
    Replies:
    1
    Views:
    464
    Chris Jackson
    Nov 13, 2003
  4. Justin

    Error-- Specified cast is not valid

    Justin, Dec 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    447
    Kevin Spencer
    Dec 3, 2003
  5. Alan Silver
    Replies:
    5
    Views:
    2,629
    Kevin Spencer
    Feb 15, 2005
Loading...

Share This Page