关于查询的问题!

Francisjp 2003-08-23 09:37:22
表单上有若干个文本框,每个文本框均是一个查询条件的输入框,当一个或几个文本框中有text的时候,就以他们作为并列的查询条件,进行查询。以一个button的click事件来触发。应该怎么实现呢?
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
changechange 2003-08-23
  • 打赏
  • 举报
回复
sub command1_click()
dim strwhere as string

if isnull(text1.value)=false then
strwhere=strwhere & " and field1='" & text1.value & "'"
end if
if isnull(text2.value)=false then
strwhere=strwhere & " and field2='" & text2.value & "'"
end if
if isnull(text3.value)=false then
strwhere=strwhere & " and field3='" & text3.value & "'"
end if
dim strsql as string
strsql="select * from tableName where field_deleted=false " & strwhere
dim strconn as string
dim conn as new adodb.connection
dim rs as new adodb.recordset
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\1.mdb;User ID=admin;Password=rr;Jet OLEDB:Database Password=1"
rs.open conn,1,1
do until rs.eof
...
rs.movenext
loop
rs.close
set rs=nothing

end sub
changechange 2003-08-23
  • 打赏
  • 举报
回复
sub command1_click()
dim strwhere as string

if isnull(text1.value)=false then
strwhere=strwhere & " and field1='" & text1.value & "'"
end if
if isnull(text2.value)=false then
strwhere=strwhere & " and field2='" & text2.value & "'"
end if
if isnull(text3.value)=false then
strwhere=strwhere & " and field3='" & text3.value & "'"
end if
dim strsql as string
strsql="select * from tableName where field_deleted=false " & strwhere
dim conn as string

end sub

1,216

社区成员

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

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