access查询的问题

shortppsy 2005-10-26 05:17:58
欲根据 combo1.text中的内容 “编号” 来查询数据库中 该编号的 XXX字段是否为""
请教一下,语法该如何写
...全文
163 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishmans 2005-10-26
  • 打赏
  • 举报
回复
sqlstr="select top 1 XXX from table where id='"+trim(Combo1.List(Combo1.ListIndex))+"'and (XXXX is null or XXXX<>'')"
rs.open cn,sqlstr,1,3
if rs.eof then
'not empty
else
'empty
end if


900126 2005-10-26
  • 打赏
  • 举报
回复
:)
crycoming 2005-10-26
  • 打赏
  • 举报
回复
sSQL="select * from tbl where bianhao='" & Combo1.text &"' and (XXXX is null or XXXX<>'')"
rs.open cn,sSQL,1,3
if rs.eof then
'not empty
else
'empty
end if
northwolves 2005-10-26
  • 打赏
  • 举报
回复
sql="select len(xxx) as nostr from 表1 where 编号=" & Combo1.text
winehero 2005-10-26
  • 打赏
  • 举报
回复
难道我真的老了吗?。。。

这个提问我左看右看,理解成了好几个意思,LZ你究竟想问什么?
seraph2 2005-10-26
  • 打赏
  • 举报
回复
combo1.text 内部是编号对吧?如果编号确定为整型且必须大于0的话可以直接使用int(combo1.text)转换成短整型,判断其大于0即可,如果不是只是""的话你可以判断 trim(combo1.text)<>empty就可以啊!empty是vb里除了对象之外的为空的判断
of123 2005-10-26
  • 打赏
  • 举报
回复
rs.Open "select * from 表1 where 编号=" & Combo1.List(Combo1.ListIndex), cn

If Not rs.EOF Then
msgbox "xxx" & iif(rs!xxx = "", "=", ">") & """""
End If
faysky2 2005-10-26
  • 打赏
  • 举报
回复
搞错:
Dim cn As New ADODB.Connection,rs As New ADODB.RecordSet
cn.ConnectionString="...."
cn.Open
rs.CursorLocation=adUseClient
rs.Open "select XXX字段 from 表 where 编号=' & Combo1.Text & "'"",cn,3,2
if Not rs.EOF then
if rs("XXX字段")="" then Msgbox "XXX字段为=""""
else
Msgbox "编号不存在!"
end if
faysky2 2005-10-26
  • 打赏
  • 举报
回复
Dim cn As New ADODB.Connection,rs As New ADODB.RecordSet
cn.ConnectionString="...."
cn.Open
rs.CursorLocation=adUseClient
rs.Open "select XXX字段 from 表 where 编号=' & Combo1.Text & "'"",cn,3,2
if Not rs.EOF then
Msgbox "XXX字段为空!"
else
Msgbox "编号不存在!"
end if
faysky2 2005-10-26
  • 打赏
  • 举报
回复
欲根据 combo1.text中的内容 “编号” 来查询数据库中 该编号的 XXX字段是否为""
--------------------------------
Dim cn As New ADODB.Connection,rs As New ADODB.RecordSet
cn.ConnectionString="...."
cn.Open
rs.CursorLocation=adUseClient
rs.Open "select XXX字段 from 表 where 编号=' & Combo1.Text & "'"",cn,3,2
if rs.Field(0).value="" then
msgbox "XXX字段为空!"
end if
aqnhdly 2005-10-26
  • 打赏
  • 举报
回复
如果编号为文本类型:
sql="select * from 表名 where 字段名='" & combo1.text & "'"
如果编号为数字类型:
sql="select * from 表名 where 字段名=" & combo1.text

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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