首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > IBM DB2 >

SQLBindParameter怎样绑定NULL值,该怎么解决

2012-02-09 
SQLBindParameter怎样绑定NULL值对于表中的时间类型,当为空时,直接插入空字符串时会报错提示时间格式不正

SQLBindParameter怎样绑定NULL值
对于表中的时间类型,当为空时,直接插入空字符串时会报错提示时间格式不正确,在SQL语句里能插入NULL值,我在C里面用SQLBindParameter该怎样绑定NULL值,写到时间类型的字段里?
SQL="INSERT CTEST (CLT_TIME) VALUES(?)"
parameter="2008-11-06 14:45:33.000000";

  cliRC = SQLBindParameter(hstmt,  
  i,  
  SQL_PARAM_INPUT,  
  SQL_C_CHAR,  
  SQL_CHAR,  
  26,
  0,  
  parameter,  
  0,  
  NULL);  
当时间有值时,是可以插入的,当为空时,就不能插入,提示An invalid datetime format was detected; that is, an invalid string representation or value was specified. SQLSTATE=22007
我该怎么做?
谢谢

[解决办法]
Just Try:
------------------------
cliRC = SQLBindParameter(hstmt,
i,
SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_CHAR,
26, 
0,
SQL_NULL_DATA, /* use this for test */
0,
NULL);

热点排行