?
Solved

Display ONLY columns from DB record that are not NULL.

Posted on 2005-04-10
4
Medium Priority
?
287 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:Bud
  • 2
4 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 13750679
//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
 
LVL 5

Expert Comment

by:Vinod_VijayanVin
ID: 13750772

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
 
LVL 5

Accepted Solution

by:
Vinod_VijayanVin earned 1000 total points
ID: 13750777
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
 
LVL 2

Expert Comment

by:axrial
ID: 13751014
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question