473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Error: Specified cast is not valid

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.

Nov 19 '05 #1
4 1342
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" <we*********@poole.gov.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr 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.

Nov 19 '05 #2
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" <we*********@poole.gov.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr 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.

Nov 19 '05 #3
On Mon, 25 Apr 2005 09:01:22 -0500, Web Team @ Borough of Poole
<we*********@poole.gov.uk> 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
Nov 19 '05 #4
Thanks everyone - Northing was indeed Nothing! :)

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ron Holmes | last post by:
I posted this question on the Crystal Reports Support site and I am still waiting for an answer. Using Crystal Reports 9.0 Developer Full edition: My Crystal report .RPT file has a Picture box...
13
by: LL | last post by:
Hi, How to fix this problem: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error...
5
by: .Net Sports | last post by:
I have a datagrid codebehind script that takes data from sql dbase and displays it in a footer row as a total. One column has amount_dollars (which works fine), while another has new sales (which...
4
by: SRLoka | last post by:
I have an application that has five threads. All five threads write to the same MSMQ. All five threads are using the same global instance to send data to the MSMQ server(on same machine)....
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
5
by: Alan Silver | last post by:
Hello, I have an ASP.NET page where I am grabbing an SqlDataReader and using it to populate some controls on the form. Amongst the fields pulled out of the table are two integer fields, which I...
1
by: .Net Sports | last post by:
I have a datagrid codebehind script that takes data from sql dbase and displays it in a footer row as a total. One column has amount_dollars (which works fine), while another has new sales (which...
0
by: kcm | last post by:
Hello all, Not sure if this is the right place to post this. I ran up the samples for adventureworks for MSSQL2005. I setup the shop front. The web site is up. But when I try to register a new...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
1
vinci
by: vinci | last post by:
Please help me out... i only have two weeks to do it... here is my code: Dim ex As New Object Dim wb As Excel.Workbook Dim sheet As Excel.Worksheet
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.