Handle null values in ADO.NET

Results 1 to 2 of 2

Thread: Handle null values in ADO.NET

  1. #1
    Join Date
    Dec 1969

    Default Handle null values in ADO.NET

    I have a form which contains 15 fields of those 15 fields 5 are required the rest are optional. I have a stored procedure that will insert all those values into the tables that they belong to . Only problem is when a value is blank I recieve a error . <BR><BR>Procedure &#039;ProcedureName&#039; expects parameter &#039;@ParamValue&#039;, which was not supplied. <BR><BR>I can use DBNULL.Value and then the error will go away but is there a easy way to have the nulls autmatically inserted or will I need to write (if) statements just to handle them. <BR><BR>Also I am using Microsoft.ApplicatinBlocks.Data for inserting these records.

  2. #2
    Join Date
    Dec 1969

    Default Have to use IF, sorry...

    ...but of course you could create a function method that you would call rather than writing the IF inline for each field.<BR><BR>The other option, of course, is to handle this in the stored procedure, converting &#039;&#039; arguments to NULL instead. Of course, even *that* doesn&#039;t work for numeric arguments (though I suppose you could pass them to the SP as text, converting &#039;&#039; to NULL and non-&#039;&#039; to numbers via CONVERT).<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts