Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass Date time Field blank value in c# and Oracle Procedure?

This is My Object Code..............
C#
 public class kNewCustomerinformation
    {
private DateTime? trade_lice_dt=null;
       private DateTime? reg_dt=null;
       private DateTime? comm_Business_dt=null;
}


This is My Oracle Procedure.............
CREATE OR REPLACE PROCEDURE SA.WSP_INS_CRM_CUSTOMER
(


VTRADE_LICE_DT IN DATE,
VREG_DT IN DATE,
comm_Business_dt DATE
VVMSG OUT VARCHAR2 ,
VVMSG_CODE OUT VARCHAR2
)

Then Insert Table and pass parameter variable value.

And my Dataservice Pass Parameter Value

fbDataAccess.FBWDatabase.AddInParameter(dbCommand, "VTRADE_LICE_DT", DbType.DateTime, objIndividualCustomerInformation.trade_lice_dt);

fbDataAccess.FBWDatabase.AddInParameter(dbCommand, "VTRADE_LICE_DT", DbType.DateTime, objIndividualCustomerInformation.reg_dt);

fbDataAccess.FBWDatabase.AddInParameter(dbCommand, "VTRADE_LICE_DT", DbType.DateTime, objIndividualCustomerInformation.comm_Business_dt);

fbDataAccess.ExecuteInsert(dbCommand);

When Execute this sp then exception "ORA-01036: illegal variable name/number".

How can pass blank Value date field.
Please Help me.
Posted
Updated 16-Sep-15 0:25am
v2
Comments
[no name] 16-Sep-15 6:32am    
Are you sure, using three times the same Parameter Name "VTRADE_LICE_DT" in your code is what you like to do?

By converting null to DbNull.Value and passing it as an object
C#
fbDataAccess.FBWDatabase.AddInParameter(dbCommand, "VTRADE_LICE_DT", DbType.DateTime, (object) objIndividualCustomerInformation.trade_lice_dt ?? DbNull.Value);
 
Share this answer
 
Hello please use this function.

C#
public static string DefaultDateIfNullOrEmpty(string value)
       {

           if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
           {
               return null;
           }
           else
           {
               return value;
           }
       }


it return null date when parameter or field is null.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900