Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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
  #1 (permalink)  
Old June 30th, 2004, 12:00 PM
Authorized User
 
Join Date: Jun 2003
Location: St. Louis, Mo., USA.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default looking for nulls

I am writing a series of queries that return values for a report, however a few of the values that are being returned are 'null' so when I attempt to use or format them I get an error. In VB6 there is a function called 'VarType' which you can use to check for nulls. Is there a function or way to do the same thing in C#?

  #2 (permalink)  
Old June 30th, 2004, 12:04 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

if(<variable> is DBNull)
  #3 (permalink)  
Old June 30th, 2004, 12:47 PM
Authorized User
 
Join Date: Jun 2003
Location: St. Louis, Mo., USA.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That did not work, however this line appears to be the answer.

if (dvCounts[0]["Sales"].Equals(System.DBNull.Value))

  #4 (permalink)  
Old June 30th, 2004, 11:28 PM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

What contol u use? Crystal_report_Viewer where do u set ur format?! Can u tell more.

Always:),
Hovik Melkomian.
  #5 (permalink)  
Old July 1st, 2004, 07:50 AM
Authorized User
 
Join Date: Jun 2003
Location: St. Louis, Mo., USA.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dvCounts is a dataview of a stored procedure, 'Sales' is the dollar amount collected. In some cases, mostly weekends, there could be no sales on a date and a null is returned, and of course tring to convert a null to a double causes an error.



Similar Threads
Thread Thread Starter Forum Replies Last Post
IN and NULLs joxa83 SQL Server 2005 8 September 29th, 2008 03:03 AM
Working around DB Nulls chroniclemaster1 ASP.NET 2.0 Basics 2 February 27th, 2008 03:11 AM
WHERE Clause, LIKE, and Nulls jurio SQL Language 5 May 28th, 2007 02:53 AM
Find Nulls jemacc SQL Server 2000 1 September 15th, 2004 01:28 PM
Handling Nulls shahchi1 ADO.NET 4 June 24th, 2004 11:29 AM





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