NullSafe Functions: Ensuring Safe Variables


Server Intellect Web Hosting Solutions


NullSafe Functions: Ensuring Safe Variables

Author: Rob Walling

Values retrieved from DataSets, ViewState, Session State, or any number of other storage mechanisms can cause errors if they comes back as DBNull or Nothing. As an example, let's say you want to retrieve a String from a DataSet. Typically, you begin by checking if the value is DBNull.Value, then casting the value to a String (if you code with Option Strict On), then checking if it's Nothing, then trimming it. A similar process applies when retrieving a String from ViewState and Session State. In this article Rob Walling offers a few functions that ensure variables returned from DataSets, ViewState, Session State, or Functions won't break your code.










More Tutorials

Also See:

Using TemplateFields in the GridView Control
"Atlas" June CTP Release
Implementing Optimistic Concurrency with the SqlDataSource
Authentication and Authorization in ASP.NET
Understanding The Web Configuration File - Part 1
Display an animated Gif during a long-running ASP.NET page call
ASP.NET Scrollable Table Server Control
DropDown Calendar
Passing Flat File to the Biztalk Orchestration
Whidbey: New Caching Techniques - Part II



Copyright© 2005 ASP Intellect | All Rights Reserved

ASP.NET Tutorials
AspNet Tutorials ASP.NET 2.0 Code Examples, Snippets and Tutorials

ASP.NET Tutorials C++ Tutorials C# Tutorials Visual Studio.NET Tutorials
.NET Framework Tutorials Mobility Tutorials Office Tutorials Visual Basic.NET Tutorials