Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2009, 07:08 AM
Authorized User
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default How can I display a null database column

Is there anyway to retrieve a null column from the database and display it on a asp control without any modification,I tried this on a column with data type bit but it gives me errors, so I had to insert 'false' if value is null to the column before retrieving and displaying it successfully.
 
Old December 4th, 2009, 08:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. you have to tell the system what to display instead of null.. if you just want an empty string, you convert it and you solve the problem...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old December 4th, 2009, 09:57 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Without getting into a theoretical discussion on what null is or isn't, it is almost always best to handle this at your data store using functions such as ISNULL (MS Sql Server) or IFNULL (MySQL) to return some default data in the event of null.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old December 4th, 2009, 12:21 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

SELECT ISNULL([Bit Column], 1) FROM [Table]

I don't know about MySQL but in MS Sql Server you can supply a default value for the column so if for some reason you have not defined that value it will be false (0) by default.

What is your reason for wanting a NULL value in that column on the INSERT?
 
Old December 4th, 2009, 12:28 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes, MySQL will allow you to specific default values for a given column.

IMHO what you are doing here (using NULL as a datatype) is bad practice. NULL is not a datatype and you shouldn't allow it to have any bearing on your application logic whatsoever.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
detailsview not updating table when null column davej ASP.NET 2.0 Professional 3 April 11th, 2007 06:59 AM
Display all NULL columns hm_naveen Oracle 2 January 5th, 2007 09:50 AM
How do you set a column to NULL in a parameter? Aaron Edwards ASP.NET 2.0 Basics 1 April 7th, 2006 11:26 PM
How do you set a column to NULL in a parameter? Aaron Edwards ADO.NET 3 April 7th, 2006 06:26 PM
Invalid Casting for Null column using ODBC rusli ADO.NET 3 December 17th, 2004 06:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.