delphi中null怎么表示

coderee 2011-09-13 04:49:23
在delphi中 if qy1.FieldByName('sh').curValue is null then
提示错误,请问在delphi中该如何判断是否为null值?
...全文
730 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
程晨c 2011-09-16
  • 打赏
  • 举报
回复
寡人常用如下方法

if Query.FieldByName('Name').IsNull then
火龙岛主 2011-09-14
  • 打赏
  • 举报
回复
标准答案:
if qy1.FieldByName('sh').IsNull then

Harryfin 2011-09-14
  • 打赏
  • 举报
回复
看到这么多人顶了一个“CurValue = nil”的回复,就觉得很好笑,你们真的知道这个属性是什么类型吗?

5楼才是正解,或者用下面的函数,这个函数是专门判断变体是不是NULL的


if VarIsNull(qy1.FieldByName('sh').curValue) then
rainychan2009 2011-09-13
  • 打赏
  • 举报
回复
学习一下
coderee 2011-09-13
  • 打赏
  • 举报
回复
应该为
qy1.FieldByName('sh').newvalue=Null
谢谢大家。
纯冰糖 2011-09-13
  • 打赏
  • 举报
回复
if Query.FieldByName('Name').IsNull then
...
coderee 2011-09-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 m617105 的回复:]
引用 2 楼 dropme 的回复:

两种方法吧:
1. if assigned(qy1.FieldByName('sh').curValue) then

2. if qy1.FieldByName('sh').curValue = nil then

++
[/Quote]

if (qy1.FieldByName('sh').curValue<>qy1.FieldByName('sh').NewValue) or (assigned(qy1.FieldByName('sh').curValue)) then

提示incompatible types

浩南_哥 2011-09-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 dropme 的回复:]

两种方法吧:
1. if assigned(qy1.FieldByName('sh').curValue) then

2. if qy1.FieldByName('sh').curValue = nil then
[/Quote]
++
dropme 2011-09-13
  • 打赏
  • 举报
回复
两种方法吧:
1. if assigned(qy1.FieldByName('sh').curValue) then

2. if qy1.FieldByName('sh').curValue = nil then
funxu 2011-09-13
  • 打赏
  • 举报
回复
nil

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧