我有這個ASP頁面。我試圖顯示metalquery的結果,列出所有訂單號。當我現在這樣做時,它只顯示第一個訂單號。有沒有辦法顯示查詢中的所有訂單號碼?ASP查詢返回
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data.Odbc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- webkit5 includes --!>
<!-- <meta content="yes" name="apple-mobile-web-app-capable" /> --!>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>Open Inkjet Orders</title>
<meta content="keyword1,keyword2,keyword3" name="keywords" />
<meta content="Description of your page" name="description" />
</head>
<body>
<div id="topbar" class="transparent">
<div id="leftnav">
<a href="Home.aspx">
<img alt="home" src="images/home.png">
</a>
<a href="OpenOrders.aspx">Open Orders</a>
</div>
</div>
<div id="content">
<%
OdbcConnection cn;
OdbcCommand cmd;
String canvasQuery = "select count(distinct(info.orderid)) from orderinfo info, orderiteminfo item where info.orderstatus = 'Open' and info.orderid = item.orderid and item.deptcode in (35) and info.duedate = DATE(NOW())";
String wallWrapQuery = "select count(distinct(info.orderid)) from orderinfo info, orderiteminfo item where info.orderstatus = 'Open' and info.orderid = item.orderid and item.deptcode in (41) and info.duedate = DATE(NOW())";
String fineartQuery = "select count(distinct(info.orderid)) from orderinfo info, orderiteminfo item where info.orderstatus = 'Open' and info.orderid = item.orderid and item.deptcode in (03) and info.duedate = DATE(NOW())";
String metalQuery = "select distinct(info.orderid) from orderinfo info, orderiteminfo item where info.orderstatus = 'Open' and info.orderid = item.orderid and item.deptcode in (48) and info.duedate = DATE(NOW())";
int canvasOpen, wallWrapOpen, fineartOpen, metalOpen;
cn= new OdbcConnection("dsn=xxxx;UID=xxxx;PWD=xxxx");
cmd=new OdbcCommand(canvasQuery,cn);
cn.Open();
OdbcDataReader DbReader = cmd.ExecuteReader();
DbReader.Read();
canvasOpen = DbReader.GetInt32(0);
cmd=new OdbcCommand(wallWrapQuery,cn);
DbReader = cmd.ExecuteReader();
DbReader.Read();
wallWrapOpen = DbReader.GetInt32(0);
cmd=new OdbcCommand(fineartQuery,cn);
DbReader = cmd.ExecuteReader();
DbReader.Read();
fineartOpen = DbReader.GetInt32(0);
cmd=new OdbcCommand(metalQuery,cn);
DbReader = cmd.ExecuteReader();
DbReader.Read();
metalOpen = DbReader.GetInt32(0);
DbReader.Close();
cn.Close();
%>
<span class="graytitle">Due Inkjet Orders</span>
<ul class="pageitem">
<li class="menu">
<span class="name">Canvas Dept: <%=canvasOpen%></span>
</li>
<li class="menu">
<span class="name">Wall Cling Dept: <%=wallWrapOpen%></span>
</li>
<li class="menu">
<span class="name">Fine Art Dept: <%=fineartOpen%></span>
</li>
<li class="menu">
<span class="name">Metal Dept: <%=metalOpen%></span>
</li>
<li>
</li>
</ul>
</div>
</body>
</html>
您考慮循環dbReader中的記錄而不是僅顯示第一個記錄? – JohnFx
您只顯示1個值,因爲這是您從代碼中獲得的所有內容。我建議使用中繼器或某種ASP.NET控件,可以通過數據綁定顯示查詢結果。 –