first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

ADO.NET: Using Default Parameters in SQL Server Stored Procedures

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
mod date: 2003-11-25T00:52:36.000Z