我正在使用Microsoft SQL Server 2005存儲過程在HTML表中發佈記錄。在HTML表格中,我有以下字段的行:entry#,打開日期,描述和所有者。隱藏<TR>基於Recordset的標記NULL值
有時,db表中的owner字段將爲NULL。發生這種情況時,我在對應於所有者的HTML表格行中有ASP response.write「N/A」。不過,我想避免這種情況,因爲它看起來多餘。相反,我希望有一種方法可以在數據庫中的所有者字段爲NULL時刪除該表中的所有行。我會如何去做這件事?我正在使用JavaScript,經典的ASP和SQL Server 2005.我的代碼如下。注 - 我完全是新手。謝謝。
'Declare Variables
Dim CN, RS, vOutputType, vSQL, vNumber, vOwner
'Connection from includes file
Set CN = GetDataConnection
vOutputType = Request.QueryString("ot")
If Request.QueryString("txtNumber") <> "" Then
vNumber = Rtrim(Request.QueryString("txtNumber"))
End If
If Request.QueryString("cboOwner") <> "" Then
vOwner = Rtrim(Request.QueryString("cboOwner"))
End If
If vNumber <> "" Or vOwner <> "" Then
vSQL = "spReport "
vSQL = vSQL & "@vNumber = '" & vNumber & "', "
vSQL = vSQL & "@vOwner = '" & vOwner & "'"
Set RS = CN.Execute(vSQL)
If IsObject(RS) Then
If Not RS.EOF Then%>
<table class="WebApps">
<tr>
<td width="5%"><h3>Entry #</h3></td>
<td width="5%"><h3>Open Date</h3></td>
<td width="5%"><h3>Description</h3></td>
<td width="5%"><h3>Owner</h3></td>
</tr>
<%RS.MoveFirst
Do While Not RS.EOF
%>
<tr>
<td><p><%= RS("ID")%></p></td>
<td><p><%= RS("OpenDate")%></p></td>
<td><p><%= RS("Description")%></p></td>
<td><p><%If (RS("OwnerName")) <> "" Then Response.Write(RS("OwnerName")) Else Response.Write("N/A")%></p></td>
</tr>
<%RS.MoveNext
Loop%>
</table>
<%End If
End If
'Close objects
Set RS = NOTHING
CN.Close
Set CN = Nothing
我選擇了做這個選項。精美的作品。謝謝! – SeanFlynn 2009-11-06 20:35:45
@baldwingrand:如果這是你接受的答案,那麼你應該通過點擊左邊的大勾來表明你的接受。 – AnthonyWJones 2009-11-07 15:46:50