.NET 1.1版本下使用日期强制转换函数,比如:
"select cast(ActionDate as char(7)) as ActionDate from ST_BookAction fetch first row only";
"select cast(ActionDate as char(7)) as ActionDate from ST_BookAction fetch first row only";
.NET 2.0平台以上,执行上述语句,就会报错SQL0445W 值 已被截断异常。
当改为执行如下语句就可以成功:
"select SUBSTR(CHAR(CURRENT DATE, ISO),1,7) as ActionDate from ST_BookAction fetch first row only"
判断原因是,CAST强制转换,如果长字段转换为短值,在.NET 1.1版本中不会抛出异常,而.NET 2.0以上就会抛出异常,录入下面的整车“月度统计”界面的查询报错如下