关于记录值为空的问题,请大家帮忙!谢谢!!

wangqiu 2003-08-22 02:41:15
问题如下

dim a as new adodb.connection
dim b as new adodb.recordset
con.Open "DSN=qianggege;uid=wq;pwd=wq;"
rs.CursorLocation = adUseClient
rs.Open "qianggege", con, adOpenKeyset, adLockOptimistic, adCmdTable
Text1.Text = rs("code")
Text2.Text = rs("name")
当我记录name为空的时候就会出现错误,我想用if then else end if 的语句排除这个毛病,但If rs("name") = Null Then
Text32.Text = " "
Else
Text2.Text = rs("name")
End If
是不对的那么那个当记录的name为空的时候我应该用什么代替
...全文
30 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangqiu 2003-08-22
  • 打赏
  • 举报
回复
怎么我揭贴以后大家都是0分呀,我可给分了
cbzdream 2003-08-22
  • 打赏
  • 举报
回复
Text2.Text = rs("name") & ""
wangqiu 2003-08-22
  • 打赏
  • 举报
回复
感谢大家!!谢谢!!三种方法都好用,谢谢大家!!揭贴了!!
lxcc 2003-08-22
  • 打赏
  • 举报
回复
Text1.Text = "" & rs("code")
Text2.Text = "" & rs("name")
of123 2003-08-22
  • 打赏
  • 举报
回复
Text2.Text = rs("name") & "" '强制转换成字符串,Null时为空串
iiboy 2003-08-22
  • 打赏
  • 举报
回复
Text1.Text = rs("code")
Text2.Text = rs("name")
程序应该会在上面的一行中出错,我认为应当这样写:
Text2.Text=IIf(IsNull(rs("name")),"",rs("name"))
WangPengAn 2003-08-22
  • 打赏
  • 举报
回复
看這樣行不:
Text2.Text =iif(isnull(rs("name")),"",rs("name"))
xayzmb 2003-08-22
  • 打赏
  • 举报
回复
这样试试:
Text2.Text = rs("name") & ""
道素 2003-08-22
  • 打赏
  • 举报
回复
If isnull(rs("name")) Then
Text32.Text = " "
Else
Text2.Text = rs("name")
End If
lihonggen0 2003-08-22
  • 打赏
  • 举报
回复
If not isnull(rs("name")) Then
Text2.Text = rs("name")
else
Text2.Text = ""
endif
zqfleaf 2003-08-22
  • 打赏
  • 举报
回复
试试
If isnull(rs("name")) Then
Text32.Text = " "
Else
Text2.Text = rs("name")
End If

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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