Link to home
Start Free TrialLog in
Avatar of Bud
BudFlag for United States of America

asked on

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?
Avatar of sajuks
sajuks

//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%>

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%>
ASKER CERTIFIED SOLUTION
Avatar of Vinod_VijayanVin
Vinod_VijayanVin
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial