Default parameters are used in SQL Server stored proc's when its corresponding SQL Parameter object is omitted. This C# code snippet omits this object when the value to be assigned to this object is null:
if(CmdName != null)
{
SqlParam = new SqlParameter("@cmdName",SqlDbType.VarChar,16);
SqlParam.Value = CmdName;
SqlCmd.Parameters.Add(SqlParam);
}
This and other methods are discussed in detail in "HOW TO: Call Stored Procedures with Optional Values in ADO.NET" (http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q321902). Unfortunately, all code examples in the article are in VB.NET.
Additionally, it can't hurt to review ".NET Data Access Architecture Guide" at:
http://msdn.microsoft.com/vcsharp/
using/understanding/security/
default.aspx?pull=/library/en-us/dnbda/html/daag.asp