Passing Null/empty string to Oracle stored procedure from asp.net

半腔热情 提交于 2019-12-02 04:55:26

You can do the following for any nullable parameters.

oleDBCmd.Parameters.Add(new OracleParameter("to_dt", OracleType.NVarChar));
if(string.IsNullOrEmpty(toDateStr)) {
    oleDBCmd.Parameters["to_dt"].Value = DBNull.Value;
} else {
    oleDBCmd.Parameters["to_dt"].Value = toDateStr;
}
oleDBCmd.Parameters["to_dt"].Direction = ParameterDirection.Input;

That way, you're not relying on string -> null conversion by the oracle adapter.

Edit: If this doesn't fix the issue, it is most possibly a mismatch between types, check NVarChar vs VarChar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!