ODAC Assigning DBNull.Value to paramater

Here we go, null is not an instance of any type, it is an invalid reference.Whereas, System.DbNull.Value, is a valid reference to an instance of System.DbNull
that represents nonexistent (e.g. NULL) values in the database.

(System.DbNull is a singleton and System.DbNull.Value gives you a reference to the single instance of that class)

The keyword null represents an invalid reference. The class System.DbNull represents a nonexistent value in a database field.

// Assigning Null value to Procedure Parameter

OracleParameter pram_IN_1 = new OracleParameter("pPACKAGE_NAME", OracleDbType.Varchar2);
pram_IN_1.Direction = ParameterDirection.Input;
pram_IN_1.Value = strPackageName != null ? strPackageName : (object)DBNull.Value;


Leave a Reply

Your email address will not be published. Required fields are marked *