Display ONLY columns from DB record that are not NULL.

I have a SQL database that users populate that contains columns that will left NULL.  How do I create an ASP page that shows the records from the DB but, does not list the columns that have NULL values?
BudAsked:
Who is Participating?
 
Vinod_VijayanVinCommented:
a small correction :-

<%while not rs.eof  %>
  <tr align="center" valign="middle">
    <td>
    <%
    if  trim(rs("field1"))  <>  "" then
          response.write rs("field1")
    else
         response.write("")
    end if
    %>
    </td>
    <td>
    <%
    if  trim(rs("field2"))  <>  "" then
         response.write rs("field2")
    else
         response.write ""
    end if
    %>
    </td>
  </tr>
<%  rs.movenext
    wend%>

0
 
sajuksCommented:
//try this
<%do while not rs.eof then %>
  <tr align="center" valign="middle">
    <td>
    <%
    if rs("field1") = "" then
         response.write ""
    else
         response.write rs("field1")
    end if
    %>
    </td>
    <td>
    <%
    if rs("field2") = "" then
         response.write ""
    else
         response.write rs("field2")
    end if
    %>
    </td>
  </tr>
<%loop%>
0
 
Vinod_VijayanVinCommented:

try the below :-
 

<%while not rs.eof then %>
  <tr align="center" valign="middle">
    <td>
    <%
    if  trim(rs("field1"))  <>  "" then
          response.write rs("field1")
    else
         response.write("")
    end if
    %>
    </td>
    <td>
    <%
    if  trim(rs("field2"))  <>  "" then
         response.write rs("field2")
    else
         response.write ""
    end if
    %>
    </td>
  </tr>
<%  rs.movenext
    wend%>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.