I am using a Microsoft SQL Server 2005 stored procedure to post records in an HTML table. In the HTML table, I have rows for the following fields: entry #, open date, description, and owner.
Sometimes, the owner field in the db table will be NULL. When this happens, I have ASP response.write "N/A" in the HTML table row corresponding to the owner. However, I'd like to avoid this, as it seems superfluous. Instead, I'm hoping there is a way to just eliminate that table row altoegether if the owner field is NULL in the db. How would I go about doing this? I'm using Javascript, classic ASP, and SQL Server 2005. My code is below. Note - I am a total newbie at all of this. Thanks.
'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