Alternativly, you can pass in null (using DBNull.Value) as the parameter's value.
Then inside your sproc you can compare the parameter with null and have all records returned. Something like this:
Code:
...
@HouseHold varchar(32)
...
SELECT Column1, Column2 FROM MyTable WHERE (HouseHold = @HouseHold OR @HouseHold = null)
When @HouseHold has a value, all records with the matching HouseHold will be filtered. If @HouseHold is null, the test will return true for all records (as @HouseHold is null all the time) and all records are returned.
To assign the value to your paramaters collection try something like this:
Code:
if (strAreaFilter.Length > 0)
{
objCommand.Parameters["HouseHold"].Value = strAreaFilter;
}
else
{
objCommand.Parameters["HouseHold"].Value = DBNull.Value;
}
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.