Im calling a SQL stored procedure from a piece of C#.net code:
SqlHelper.ExecuteDataset(sqlConnection, CommandType.StoredProcedure, STORED_PROC_NAME, sqlPara
I use a method to convert to DBNull if it is null
// Converts to DBNull, if Null
public static object ToDBNull(object value)
{
if (null != value)
return value;
return DBNull.Value;
}
So when setting the parameter, just call the function
sqlComm.Parameters.Add(new SqlParameter("@NoteNo", LibraryHelper.ToDBNull(NoteNo)));
This will ensure any nulls, get changed to DBNull.Value, else it will stay the same.