August 12, 2009

Accommodating Null Values in SQL Server

espite having a good understanding of the term null, most developers still fail to adequately accommodate null values in their databases. Accommodating null values appropriately is an important part of protecting the validity of your data. At the very least, mismanaging nulls leads to erroneous data. If you don’t catch

Adding an Installer Class to a Windows Service

Visual Studio makes it simple to add an installer class to your Windows service. Here are the steps: Open the “Solution Explorer” (press Ctrl-Alt-L, or go to the “View” menu and select Solution Explorer). Right-click on the appropriate code type for your service (e.g. “*.vb”) and choose “View Designer.” For

Launching an Asynchronous Operation Using BackgroundWorker

The BackgroundWorker class in the System.ComponentModel namespace (in the .NET Framework 2.0 and later) lets you launch time-consuming operations on a separate thread, which helps keep your user interface (UI) responsive. In contrast, running long time-consuming operations on the main thread blocks the whole UI, essentially “freezing” it until the

Binding a Hashtable to a DropDownList Web Server Control

When you need to bind a Hashtable to a DropDownList control, rather than iterating through all the items in the Hashtable, creating ListItem objects, and adding them to the Items collection of the DropDownList, simply use the Value and Key properties of the Hashtable to bind the data. The following

Avoid Multiple Queries When Querying for Max and Min Values

Often, when you need to get the maximum or minimum value for a specific column, you are also interested in getting more data about those particular rows, so you end up writing two queries. That’s not bad when the queries are simple, but if you have a long-running query that

Determining Merge Errors in a Typed DataSet

Merging typed DataSets can cause a “Merge Constraint” error, which explains the problem, but doesn’t help much in solving it. Here’s how to find the exact cause of the error: try{ //set Constrainsts check to false, so that the merge is fast. datasetOne.EnableConstraints = false; dbHelper.ExecuteDataSet(datasetOne, “dsOne”, “spname”); //Any error