我换了另一种方式查询测试,结果还是会有这个错误提示 另一种方式:(我添加一个字段sfls字符型字段) select * from zszb where ((lhdh=@lhdh) and year(lsrq)=year(@cxrq) and month(lsrq)=month(@cxrq)) or ((lhdh=@lhdh) and (sfls='否'))order by lhdh 昨天这种方式 select * from zszb where ((lhdh=@lhdh) and year(lsrq)=year(@cxrq) and month(lsrq)=month(@cxrq)) or ((lhdh=@lhdh) and (lsrq is null)) order by lhdh 两种查询在SQL测试中都可以通过(测试时,输入参数为实参),结果都相同,可是在VB中运行后,查询结果遇到LSRQ为空值则提示“无效使用NULL”。(lsrq有空值也有非空值呀)
你昨天的提问,表述得很清楚,我也回复了,告诉你当lsrq为null时,year(lsrq)会出错。请重新考虑查询条件。
另一种方式:(我添加一个字段sfls字符型字段)
select * from zszb where ((lhdh=@lhdh) and year(lsrq)=year(@cxrq) and month(lsrq)=month(@cxrq)) or ((lhdh=@lhdh) and (sfls='否'))order by lhdh
昨天这种方式
select * from zszb where ((lhdh=@lhdh) and year(lsrq)=year(@cxrq) and month(lsrq)=month(@cxrq)) or ((lhdh=@lhdh) and (lsrq is null)) order by lhdh
两种查询在SQL测试中都可以通过(测试时,输入参数为实参),结果都相同,可是在VB中运行后,查询结果遇到LSRQ为空值则提示“无效使用NULL”。(lsrq有空值也有非空值呀)