473,386 Members | 1,924 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,386 software developers and data experts.

MSDN provided code throws an exception!

Hi everyone. I am new to dotnet so I've been trying toread up and I
run into this frustrating situation.

I downloaded the code below from MSDN at
http://msdn2.microsoft.com/en-us/library/ms996485.aspx

Private Sub dataGrid1_CurrentCellChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DataGrid1.CurrentCellChanged
'if click on a discontinued row, then set currentcell to checkbox
Dim discontinuedColumn As Integer = 0
Dim val As Object = Me.DataGrid1( _
Me.DataGrid1.CurrentRowIndex, _
discontinuedColumn)
Dim productDiscontinued As Boolean = CBool(val)
If productDiscontinued Then
Me.DataGrid1.CurrentCell = _
New DataGridCell( _
Me.DataGrid1.CurrentRowIndex, _
discontinuedColumn)
End If
End Sub

The above is an exact copy of teh code in the aove referenced MSDN
page.

The compiler throws an exception saying "Cast from type 'DBNull' to
type 'Boolean' is not valid" when it gets to this line:
Dim productDiscontinued As Boolean = CBool(val)
The datagrid is populated i.e. there are no nulls
I am using vs.net 2003 if it makes any difference.

What could I be doing wrong?

Thanks in advance
Bill

Feb 18 '08 #1
0 664

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

Similar topics

1
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
2
by: Daniel | last post by:
if System.IO.StreamWriter write throws an exception, is there anyway to close the System.IO.StreamWriter object? it seems to stay open when this happens then future attempts to write to that same...
4
by: Jeff Louie | last post by:
This afternoon I coded a prototype user defined structure for use as a return value. The structure wraps a boolean value, the source and an error message. Comments appreciated. ...
9
by: swartzbill2000 | last post by:
Hello, I am trying to build and run the Remoting Sample from MSDN. Everything compiles. The Listener appears to run. The Client throws this RemotingException: A first chance exception of type...
4
by: mjahabarsadiq | last post by:
HELLO FRIENDS I HAVE ONE JAVA CODE WHICH PARSES AN XML FILE AND PRODUCE A QUERY TO CREATE TABEL IN A DATABASE. BUT I NEED THE CODE TO BE USED IN A JSP PAGE. HOW TO USE THIS PAGE WITH JSP. ...
10
by: George2 | last post by:
Hello everyone, Here is a sample from Dr. Dobb C++. In the analysis, the code is bad below. But I do not think the code is bad, 1. if bad_alloc is thrown in new int, we just catch it and...
2
by: SeniorLee | last post by:
in the book EC++ chapter 11, with this code ( pb is a member of class ) WIdget& WIdget::operator=(const WIdget& rhs) { Bitmap *pOrig = pb; pb = new Bitmap(*rhs.pb); delete pOrig;
7
by: louis08 | last post by:
When i call: OdetteFTPEntity oftp = session.acceptConnection(transport); I recive a java.nio.BufferOverflowException
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.