在oracle中,
query1.SQL.Text:='select R.* from table1 R'
query1.open;
.....
edit1.text:=query1.FieldByName('AA').Value;
.......
当query1.FieldByName('AA').Value为空时提示“could not convert variant of type(NULL) into type(string)"
有没有好的方法避免这种错误?回复就有分!多谢!
query1.SQL.Text:='select R.* from table1 R'
query1.open;
.....
edit1.text:=query1.FieldByName('AA').Value;
.......
当query1.FieldByName('AA').Value为空时提示“could not convert variant of type(NULL) into type(string)"
有没有好的方法避免这种错误?回复就有分!多谢!
edit1.text := ...;
except
end;
query1.SQL.Text:='select R.* from table1 R where R.aa is not null '
query1.open;/////////////////////
做如上修改,限制空值出现。
edit1.text:=query1.FieldByName('AA').Value;
...
SELECT EMPNO, NVL(ENAME,chr(0)),nvl(to_char(HIREDATE,'yyyy/mm/dd hh24:mi:ss'),chr(0)),NVL(SAL,0) FROM EMP;
这样也不会有-1405错误不,当取出的值是NULL时,自动用NVL()中指定的值代替.
CHR(0)也可直接用''代替,如下:
SELECT EMPNO, NVL(ENAME,''),nvl(to_char(HIREDATE,'yyyy/mm/dd hh24:mi:ss'),''),NVL(SAL,0) FROM EMP;
if query1.FieldByName('AA').isEmpty then
edit1.text:=''
else edit1.text:=query1.FieldByName('AA').Value;