• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 十天學會ASP之第六天

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    學習目的:學會 數據庫 的基本操作2(查詢記錄) 在第四天中我們有這樣一個程序: % set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};dbq="server.mappath("example3.mdb") exec="select * from gue

    學習目的:學會數據庫的基本操作2(查詢記錄)
        在第四天中我們有這樣一個程序:
    <%
    set conn=server.createobject("adodb.connection")
    conn.open "driver={microsoft aclearcase/" target="_blank" >ccess driver (*.mdb)};dbq="&server.mappath("example3.mdb")
    exec="select * from guestbook"
    set rs=server.createobject("adodb.recordset")
    rs.open exec,conn,1,1
    %>
    我們查詢的是所有的記錄,但是我們要修改、刪除記錄的時候不可能是所有記錄,所有我們要學習檢索合適的記錄。先看一條語句:
    a="張三"
    b=111
    exec="select * from guestbook where name='"+a+"'and tel="+b
    where后面加上的是條件,與是and,或是or,我想=,<=,>=,<,>的含義大家都知道吧。這句話的意思就是搜索name是張三的,并且電話是111的記錄。還有一點就是如果要搜索一個字段里面是不是包含一個字符串就可以這么寫:where instr(name,a)也就是搜索name里面有a(張三)這個字符串的人。
    我這里的a,b,是常量,大家可以讓a,b是表單提交過來的變量,這樣就可以做一個搜索了。
    下面大家看看這個代碼,理解一下:
    <form name="form1" method="post" action="example6.asp">
    搜索:<br>
    name =
    <input type="text" name="name">
    and tel=
    <input type="text" name="tel">
    <br>
    <input type="submit" name="Submit" value="提交">
    <input type="reset" name="Submit2" value="重置">
    </form>


    example6.asp:
    <%
    name=request.form("name")
    tel=request.form("tel")
    set conn=server.createobject("adodb.connection")
    conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("example3.mdb")
    exec="select * from guestbook where name='"+name+"' and tel="+tel
    set rs=server.createobject("adodb.recordset")
    rs.open exec,conn,1,1
    %>
    <html>
    <head>
    <title>無標題文檔</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <%
    do while not rs.eof
    %><tr>
    <td><%=rs("name")%></td>
    <td><%=rs("tel")%></td>
    <td><%=rs("message")%></td>
    <td><%=rs("time")%></td>
    </tr>
    <%
    rs.movenext
    loop
    %>
    </table>
    </body>
    </html>

    今天實際上就講了一個where,大家回去做做試驗,把instr()做進去,明天見!


    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>