lol符文收集者头像:vb中的select查找数据

来源:百度文库 编辑:高校问答 时间:2024/05/08 18:45:16
例如我在vb中的学生这个表中查找名字叫张山的全部记录并把他显示出来怎么做啊?
谢谢!
要显示出来的怎么做啊!
比如说在textbox中显示出来!

模糊查询:select * from 学生 where name like \'张三\'

cnn为数据库联接, rst为记录集, sql为查询语句
sql="select * from 学生 where name='张山'"
rst.open sql,cnn,adopenkeyset,adlockreadonly,adcmdtext
if not rst.eof then
text1.text=rst.fileds("字段1")
.......
textn.text=rst.fileds("字段n")
else
msgbox "查无此人!"
end if
rst.close
set rst=nothing

<%
set rs=server.createobject("adodb.recordset")
sql="select * from 学生 where name = '张山'"
rs.open sql,conn,1,1
%>

<table cellpadding=0 cellspacing=0 border=0 align=center>

<% do while not rs.eof %>
<tr>
<td><%=rs("name")%></td>
<tr>
<%
rs.movenext
loop
%>

</table>

<%
rs.close
set rs=nothing
%>

不好意思,没看清题目。我写的是asp里的,呵呵

模糊查询:select * from 学生 where name like '张三'
精确查询:select * from 学生 where name = '张三'
根据情况确定你使用哪种查询!!

SQL = “select * from 学生 where 名字 = '张山'”

select * from 学生 where name = '张山'