请问:我建立了一个数据库“ffyy”,字段有“姓名、性别、编号、职位”四个,当输入任意一个或多个字段时的数据库查询如何实现?
解决方案 »
- 求助,关于Win32_Process的cmd进程的路径获取
- 有人研究NP(nProtect GameGuard)没?[
- 关于字符集的问题
- 怎样用对一个文件进行base64编码?谢了,最好有源码!
- 为什么Serve2000修改管理员密码后,SQL SERVER不能启动?
- 纠正“WINSOCK一次最多传送8K”的错误说法,让我走了很多弯路
- 位机种用WINSOCK获得的GPRS终端的IP,却与这个终端自身显示的不同
- 急!请问:怎样屏蔽webbrowser控件浏览网页时弹出的错误窗口,像javascript的错误之类的。谢谢!
- 我将资源文件写入DLL在程序中调用,可否有函数可以往这个DLL里写数据,如修改字符串
- 怎样用VB实现多文件查找与替换功能
- inet控件:运行时提示“仍在执行上一请求”???!!!!!!
- 用CryptEncrypt加密后的字符串比原来短了?
if 姓名值<>"" then sql=" 姓名 like '%姓名值%'"
if 性别值<>"" then sql & sql=" and 性别 like '%性别值%'"
if 编号值<>"" then sql & sql=" and 编号 like '%编号值%'"
if 职位值<>"" then sql & sql=" and 职位 like '%职位值%'"
if left(sql,4)=" and" then
sql=right(sql,len(sql)-4)
end if
if sql<>"" then
rs.open "select * from ffyy where" & sql
else
rs.open "select * from ffyy"
endif
dim sql as stringif 姓名值<>"" then sql=" 姓名 like '%姓名值%'"
if 性别值<>"" then sql & sql=" and 性别 like '%性别值%'"
if 编号值<>"" then sql & sql=" and 编号 like '%编号值%'"
if 职位值<>"" then sql & sql=" and 职位 like '%职位值%'"
if left(sql,4)=" and" then
sql=right(sql,len(sql)-4)
end if
if sql<>"" then
rs.open "select * from ffyy where" & sql
else
rs.open "select * from ffyy"
endif
sql="select * from ffyy "
dim condition as string
condition=""
if txtName.text<>"" then condition= "姓名='" & txtName.text & "' "
if txtSex.text<>"" then
if condition="" then
condition="性别='" & txtSex.text & "' "
else
condition=condition & " and 性别='" & txtSex.text & "' "
end if
..同上将编号和职位写完..
if condition<>"" then sql=sql & " where " & condition
执行查询
xsp(半个程序员) 的比较全面!
xsp(半个程序员) 的全面在哪里?
dim tmp_name as string
dim tmp_sex as string
dim tmp_code as string
dim tmp_job as string
if 姓名值<>"" then
tmp_name=" and 姓名 like '%姓名值%'"
else
tmp_name=""
endif
if 性别值<>"" then
tmp_sex=" and 性别 like '%性别值%'"
else
tmp_sex=""
endif
if 编号值<>"" then
tmp_code=" and 编号 like '%编号值%'"
else
tmp_code=""
endifif 职位值<>"" then
tmp_job=" and 职位 like '%职位值%'"
else
tmp_job=""
endif
'组合查询
strsql=" select * from ffyy where 1=1 " & tmp_name & tmp_sex & tmp_code & tmp_jobif rs.state=adstateopen then rs.close
rs.open strsql,conn,3,3