Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Cast from type 'DBNull' to type 'Boolean' is not valid

Thread Tools

Re: Cast from type 'DBNull' to type 'Boolean' is not valid

Mike Newton
Posts: n/a
Ibrahim Shameeque wrote:

> Sunil
> Your field item is returning a null value. Please make sure that it returns only 1 or 0 by checking if allow nulls is switched off in the table. You can also check for null conditions in your code.


The easiest way to do it (especially if you don't have edit access to
the table) is to just include the DBNull check first in your conditional.

if ((dtrDisplayProfessionalExams.Items["Field"] != DBNull.Value) &&


That's the C# solution at least. There is a different keyword in VB.Net
that allows you to do an if statement like that.
Reply With Quote

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
Is the result of valid dynamic cast always equal to the result ofcorrespondent static cast? Pavel C++ 7 09-18-2010 11:35 PM
Cast from string "Thu Jul 21 00:00:00 UTC+0100 200" to type 'Date'is not valid(System.InvalidCastException) Kiran ASP .Net 1 08-04-2005 10:01 AM
Cast from type 'DBNull' to type 'String' is not valid. tshad ASP .Net 6 12-15-2004 05:10 PM
Cast from type 'DBNull' to type 'String' is not valid. Elmo Watson ASP .Net 3 12-25-2003 03:30 AM
Cast from type 'DBNull' to type 'String' is not valid error Rob ASP .Net Datagrid Control 0 07-28-2003 09:11 PM