⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ado_query.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>ADO Queries</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

<h1>ADO Queries</h1>
<a href="ado_display.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="ado_sort.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />

<p class="intro">We may use SQL to create queries to specify 
only a selected set of records and fields to view.</p>
<hr />
<h2>Examples</h2>
<p>
<a target="_blank" href="showasp.asp@filename=demo_query_1">Display records 
where &quot;Companyname&quot; starts with an A</a><br />
How to display only the records from the &quot;Customers&quot; table that have a &quot;Companyname&quot; 
that starts with an A.</p>
<p>
<a target="_blank" href="showasp.asp@filename=demo_query_2">Display records 
where &quot;Companyname&quot; is &gt; E</a><br />
How to display only the records from the &quot;Customers&quot; table that have a &quot;Companyname&quot; 
that is larger than E.</p>
<p>
<a target="_blank" href="showasp.asp@filename=demo_query_3">Display only Spanish 
customers</a><br />
How to display only the Spanish customers from the &quot;Customers&quot; table.</p>
<p>
<a target="_blank" href="showasp.asp@filename=demo_query_4">Let the user choose 
filter</a><br />
Let the user choose which country to show customers from.</p>
<hr />
<h2>Display Selected Data</h2>
<p>We want to display only the records from the &quot;Customers&quot; table that have a &quot;Companyname&quot; 
that starts with an A (remember to save the file with an .asp extension):</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr>
    <td>
      <pre>&lt;html&gt;
&lt;body&gt;</pre>
      <pre>&lt;%
set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Provider=&quot;Microsoft.Jet.OLEDB.4.0&quot;
conn.Open &quot;c:/webdata/northwind.mdb&quot;</pre>
      <pre>set rs=Server.CreateObject(&quot;ADODB.recordset&quot;)
sql=&quot;SELECT Companyname, Contactname FROM Customers
WHERE CompanyName LIKE 'A%'&quot;
rs.Open sql, conn
%&gt;</pre>
      <pre>&lt;table border=&quot;1&quot; width=&quot;100%&quot;&gt;
  &lt;tr&gt;
  &lt;%for each x in rs.Fields
    response.write(&quot;&lt;th&gt;&quot; &amp; x.name &amp; &quot;&lt;/th&gt;&quot;)
  next%&gt;
  &lt;/tr&gt;
  &lt;%do until rs.EOF%&gt;
    &lt;tr&gt;
    &lt;%for each x in rs.Fields%&gt;
      &lt;td&gt;&lt;%Response.Write(x.value)%&gt;&lt;/td&gt;
    &lt;%next
    rs.MoveNext%&gt;
    &lt;/tr&gt;
  &lt;%loop
  rs.close
  conn.close%&gt;
&lt;/table&gt;</pre>
      <pre>&lt;/body&gt;
&lt;/html&gt;</pre>
    </td>
  </tr>
</table>
<p>Here is the result:</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
        <tr>
          <th>Companyname</th>
          <th>Contactname</th>
        </tr>
        <tr>
          <td>Alfreds Futterkiste</td>
          <td>Maria Anders</td>
        </tr>
        </table>
<br />
<hr />
<a href="ado_display.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="ado_sort.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -