當前位置:編程學習大全網 - 源碼下載 - 求壹個ASP加access編寫的查詢代碼

求壹個ASP加access編寫的查詢代碼

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%

'連接數據庫,數據庫名為phone

Dim conn,db

db="db/phone.mdb" '數據庫路徑

Set conn=Server.CreateObject("adodb.connection")

conn.ConnectionString="provider = microsoft.jet.oledb.4.0;data source="&Server.MapPath(db)

conn.Open

If Err Then

Err.Clear

Set conn = Nothing

Response.Write "數據庫連接失敗"

Response.End

End If%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns="http://www.w3.org/1999/xhtml">

<Head>

<Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<Title>ASP加access編寫的查詢代碼</Title>

</Head>

<Body>

<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="341" height="29" align="center">編號</td>

<td width="396" align="center">手機號</td>

<td width="223" align="center">?</td>

</tr>

<% Dim rs

set rs=server.CreateObject("adodb.recordset")

sql="select * from user"

rs.open sql,conn,1,1

if rs.eof and rs.bof then

response.write"沒有數據"

end if

for i = 1 to rs.recordcount

if rs.eof then exit for%>

<tr>

<td height="28" align="center"><%=rs("bianhao")%></td>

<td align="center"><%=rs("phone")%></td>

<td align="center">?</td>

</tr>

<%rs.movenext

next%>

<form action="" method="post" name="chaxvn"> <tr>

<td height="28" align="center">手機號:<input type="text" name="soso" /></td>

<td align="left"><input type="submit" name="send" value="查詢" /></td>

<td align="center">?</td>

</tr>

</form>

<% if request.form("send")="查詢" then

if request.form("soso")="" then

response.write"<script>alert('請輸入手機號!');history.back();</script>"

response.end

end if

set rsc=server.CreateObject("adodb.recordset")

sqlc="select * from user where phone='"&request.form("soso")&"'"

rsc.open sqlc,conn,1,1

if rsc.eof and rsc.bof then

response.write"沒有數據"

else%>

<tr>

<td height="28" align="center"><%=rsc("bianhao")%></td>

<td align="center"><%=rsc("phone")%></td>

<td align="center">?</td>

</tr>

<% end if

end if%>

</table>

</Body>

</Html>

  • 上一篇:IOS中如何Hook消息
  • 下一篇:奇幻app源代碼
  • copyright 2024編程學習大全網