0

我有一个 SQL 数据库,我已成功连接到该数据库,并将其显示在我的网页上。数据库中有很多空字段,所以当我在浏览器的表格中显示信息时,您会看到很多空字段。我尝试过使用空单元格功能,但这似乎不起作用。所以我想在空白字段中添加“NULL”这个词。

我已经问过这个问题了,但是因为我的问题有点含糊,所以它被关闭了。请参阅下面的表格代码:

<div id="displayBox" style="border: 3px solid #9C9595; height: 750; width: 1000px" class="blackBox">
<h2> View Sim Details </h2>
<table class="myTable" border="5">
<tr>
<th id="">ID</th>
<th id="">Number</th>
<th id="">Sim Card</th>
<th id="">ACCOLC</th>
<th id="">Notes</th>
<th id="">Next Upgrade</th>
<th id="">Pin</th>
<th id="">Puk</th>
<th id="">End Date</th>
<th id="">Update</th>
</tr>
</div>
4

1 回答 1

2

使用 ASP 经典,您可以简单地执行以下操作:

<td><%=StringIfNull(rs("SomeValue"))%></td>

function StringIfNull(value)
    StringIfNull = value

    if isnull(StringIfNull) then
        StringIfNull = "Null"
    end if
end function

或者您可以在数据库级别处理此问题:

SELECT ISNULL(SomeValue, 'Null') AS SomeValue FROM MyTable
于 2013-01-31T13:48:07.467 回答