发布网友 发布时间:2024-10-24 00:25
共2个回答
热心网友 时间:2024-10-28 03:01
<%
dim sn '记录输入的查询条件
dim conn '记录连接对象
dim rec '记录结果集变量
dim str '记录查询的字符串
sn=request.queryString("t1")
set conn=server.CreateObject("adodb.connection")
set rec=server.CreateObject("adodb.recordset")
conn.connectionString="driver=sql server;server=127.0.0.1;uid=sa;pwd=;database=pubs"
conn.open
str="select au_id,au_lname,au_fname,phone,address,city from authors where au_lname like '%" & sn & "%'"
'response.Write(str) '显示字符串
set rec=conn.execute(str)
if rec.eof=true then
response.Write("<h2>没有符合条件的作者</h2>")
response.Write("<p align=right><a href=input.asp>返回</a></p>")
else
response.write("<table width=100% align=center border=1 bordercolor=orange>")
response.Write("<tr><th>编号</th><th>名字</th><th>电话</th><th>城市</th><th>地址</th></tr>")
do while rec.eof=false
response.Write("<tr align=center>")
response.Write("<td>" & rec("au_id") & "</td>")
response.Write("<td>" & rec("au_lname") & " " & rec("au_fname") & "</td>")
response.Write("<td>" & rec("phone") & "</td>")
response.Write("<td>" & rec("city") & "</td>")
response.Write("<td>" & rec("address") & "</td>")
response.Write("</tr>")
rec.movenext
loop
response.Write("</tale>")
end if
%>
上面的例子是查询,插入只需将变量str的sql的select语句改成ingsert语句就欧了
热心网友 时间:2024-10-28 03:02
查资料啊