如何在c#和Oracle过程中传递日期时间字段空白值 [英] How to pass Date time Field blank value in c# and Oracle Procedure
问题描述
如何在c#和Oracle过程中传递日期时间字段空白值?
这是我的对象代码............ ..
How to pass Date time Field blank value in c# and Oracle Procedure?
This is My Object Code..............
public class kNewCustomerinformation
{
private DateTime? trade_lice_dt=null;
private DateTime? reg_dt=null;
private DateTime? comm_Business_dt=null;
}
这是我的Oracle程序.............
创建或更换程序SA.WSP_INS_CRM_CUSTOMER
(
VTRADE_LICE_DT日期,
VREG_DT日期,
comm_Business_dt日期
VVMSG OUT VARCHAR2,
VVMSG_CODE OUT VARCHAR2
)
然后插入表并传递参数变量值。
和我的Dataservice Pass参数值
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);
当执行此sp然后异常时 ORA-01036:非法变量名称/号码。
如何传递空白值日期字段。
请帮助我。
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.
推荐答案
将null
转换为DbNull.Value并传递给它作为对象
By convertingnull
toDbNull.Value and passing it as an object
fbDataAccess.FBWDatabase.AddInParameter(dbCommand, "VTRADE_LICE_DT", DbType.DateTime, (object) objIndividualCustomerInformation.trade_lice_dt ?? DbNull.Value);
您好请使用此功能。
Hello please use this function.
public static string DefaultDateIfNullOrEmpty(string value)
{
if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
{
return null;
}
else
{
return value;
}
}
当参数或字段为空时返回null日期。
it return null date when parameter or field is null.
这篇关于如何在c#和Oracle过程中传递日期时间字段空白值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!