数据库查询问题,急!!!有分哟~~ (一个很菜的问题~~)

showwu 2002-03-18 08:06:57
我有一通信录的库,想做一个查询的程序,点击查询后,弹出一个frame,上面有姓名,性别,联系电话,如果我按这些条件查询怎么写语句,我的这个怎么老是出错,我真的很菜,教教我吧,我急用!!!

Option Explicit
allinfo="select name as 姓名,sex as 性别,telephone as 联系电话,address as _地址,zip as 邮编 from 通信录"

private sub command1_click()
dim t,m,n as string
if IsNumeric(text1.text) then
m="name"+text1.text
end if
if IsNumberic(text2.text) then
n="sex"+text2.text
end if
if m="" and n="" then
t=""
else
if m="" then
t=n
else
if n="" then
t=m
else
t=m+" and "+n
end if
end if
end if
if t<>"" then
t="where"+t
end if
adodc1.recordsource=allinfo+t
adodc1.commandtype=adcmdtext
adodc1.refresh
end sub

而且adodc1.refresh那句还老出错,说至少有一个参数未设置,帮帮忙哟~~`

...全文
32 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
showwu 2002-03-18
  • 打赏
  • 举报
回复
think you ~~~原来是它没定义~~
hongtao924 2002-03-18
  • 打赏
  • 举报
回复
粗看了一下
你的allinfo变量没有申明呀.
dim allinfo as string
showwu 2002-03-18
  • 打赏
  • 举报
回复
按姓名,或按性别
jingxiaoping 2002-03-18
  • 打赏
  • 举报
回复
按什么条件呀?
showwu 2002-03-18
  • 打赏
  • 举报
回复
要是有时拥护只填了text1,而没填text2,这样构成一个select语句怎么写呀
showwu 2002-03-18
  • 打赏
  • 举报
回复
我用的是adodc
daryl715 2002-03-18
  • 打赏
  • 举报
回复
select * from 表名称 where 姓名='" & text1.text &"'" and 地址='" & text2.text &"'"
如果还有条件可以继续and
showwu 2002-03-18
  • 打赏
  • 举报
回复
我用的是 adodc
showwu 2002-03-18
  • 打赏
  • 举报
回复
我就是想按条件查询,一般的应该怎样写呀
谢谢
jingxiaoping 2002-03-18
  • 打赏
  • 举报
回复
看样子你用的是ADODC吧,这些语句有错误:不过还是看了半天没有看明白,把你的意图说一下吧。

1,217

社区成员

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

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