Calling from db gives unwanted 'null' response

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Calling from db gives unwanted 'null' response

    Hello,

    I'm trying to get a code to work wherein I'd like to display
    information, some of which may or may not be blank from a database
    onto a webpage. Currently, the output is as in the following example:

    John Smith
    null
    123 Main St

    I'd like the null to be ignored. Any ideas??

    Here is my code:

    <%
    var tbl="";
    var rs = Server.CreateObject("ADODB.Recordset");
    var sql = "SELECT DISTINCT Photos.Photo, Photos.Artist,
    Artists.Organization, Artists.Address1 FROM Photos, Artists WHERE
    Photos.Artist = Artists.Artist";

    rs.Open(sql,strconnection);
    var n=0;
    while (!rs.EOF)
    {
    var img = rs.Fields("Photo");
    var art = rs.Fields("Artist");
    var org = rs.Fields("Organization");
    var ad1 = rs.Fields("Address1");
    {
    var tbl = tbl += "<table border='0'>\n";
    {
    tbl += " <td>\n";
    tbl += " <IMG src='images/" + img + "'>\n";
    tbl += " </td>\n";
    tbl += " <td>Artist:" + art + " \n";
    tbl += " <br>" + org + "\n";
    tbl += " <br> " + ad1 + "\n";
    }
    tbl += "</table>\n";
    }
    rs.MoveNext();
    n++;
    }
    rs.Close();
    Response.Write("document.repForm.write('" + tbl + "')")
    %>
    </script>
    </head>
    <html>
    <BODY>

    <%=tbl%>

    </BODY>
    </HTML>
    Jeremy Guest

  2. Similar Questions and Discussions

    1. Calling a fuction from a response Handler
      I use a function with remote call to populate a grid with data and it works fine. function getStudentAll() { <cfoutput> var...
    2. null object returnd to .net client while calling axis web service
      Hi , I have a java web services (message style web service whichreturns document object) on axis and im trying to access it fromvb.net client. It is...
    3. Slow login response response on TS 03 in AD mixed mode
      We upgraded our NT 4 domain to an AD mixed until we get rid of the NT 4 BDC;s after completing this upgrade users began complaining about how long...
    4. Newbie: null response when switching from framework 1.0 to 1.1
      Hi, in the past days I've been fighting with a strange situation. We have to build an application able to get some information from a soap server....
    5. AW7 vs. DirectorMX for psychology experiment using response times AND response answers
      Hello, I'm very new to application design, but need to develop a web based application to use at multiple schools as part of an experimental...
  3. #2

    Default Re: Calling from db gives unwanted 'null' response

    Perhaps change this:
    tbl += " <br>" + org + "\n";

    To be more like this:
    If Not IsNull(Org) Then
    tbl = tbl & " <br>" & org & "\n";
    End If

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

  4. #3

    Default Re: Calling from db gives unwanted 'null' response

    Thanks for your response, although if I do that, I get the following error:

    Error Type:
    Microsoft JScript compilation (0x800A03EC)
    Expected ';'
    /iti/fpdb/Forms/photogallery.asp, line 41, column 3
    If Not IsNull(Org) Then
    --^



    Bullschmidt <paul@bullschmidt.com-nospam> wrote in message news:<e3BjbGg9DHA.2524@TK2MSFTNGP11.phx.gbl>...
    > Perhaps change this:
    > tbl += " <br>" + org + "\n";
    >
    > To be more like this:
    > If Not IsNull(Org) Then
    > tbl = tbl & " <br>" & org & "\n";
    > End If
    >
    > Best regards,
    > J. Paul Schmidt, Freelance ASP Web Developer
    > [url]http://www.Bullschmidt.com[/url]
    > ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    Jeremy Guest

  5. #4

    Default Re: Calling from db gives unwanted 'null' response

    Jeremy wrote:
    > Thanks for your response, although if I do that, I get the following
    > error:
    >
    > Error Type:
    > Microsoft JScript compilation (0x800A03EC)
    > Expected ';'
    > /iti/fpdb/Forms/photogallery.asp, line 41, column 3
    > If Not IsNull(Org) Then
    > --^
    That's vbscript, not jscript. Here's the jscript version:
    if (Org != null) {

    HTH,
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  6. #5

    Default Re: Calling from db gives unwanted 'null' response

    > Perhaps change this:
    > tbl += " <br>" + org + "\n";
    >
    > To be more like this:
    > If Not IsNull(Org) Then
    > tbl = tbl & " <br>" & org & "\n";
    > End If
    In JScript syntax:
    tbl += (org) ? " <br>" + org + "\n" : "";

    MC



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.577 / Virus Database: 366 - Release Date: 04/02/04


    The Mighty Chaffinch Guest

  7. #6

    Default Re: Calling from db gives unwanted 'null' response

    I appreciate all of your responses, but none of these solutions seem
    to work. They don't give an error, but they don't remove the 'null'
    either....
    Jeremy Guest

  8. #7

    Default Re: Calling from db gives unwanted 'null' response

    > I appreciate all of your responses, but none of these solutions seem
    > to work. They don't give an error, but they don't remove the 'null'
    > either....
    If you post the ASP/JScript code after the changes, also the HTML that this
    produced (use View/Source in yr browser) then I'm sure someone here can
    figure it out.

    I noticed a couple of other things:
    1) I'm unsure about the effect of using the \n char in server-side JScript,
    I always use <BR> myself.
    2) Where you use code like:
    var art = rs.Fields("Artist");
    I always use:
    var art = rs.Fields("Artist").Value;

    It could be that the 2nd point is causing yr problem: you may be getting the
    string "null" from the field instead of the value null.

    HTH

    MC


    The Mighty Chaffinch Guest

  9. #8

    Default Re: Calling from db gives unwanted 'null' response

    That did it! Thanks... it was the .values that was holding the whole
    thing up... It's always something little isn't it?

    Thanks for all the help!

    Jeremy

    "The Mighty Chaffinch" <MightyChaffinch@hotmail.com> wrote in message news:<OwT50Zx9DHA.2644@TK2MSFTNGP11.phx.gbl>...
    > > I appreciate all of your responses, but none of these solutions seem
    > > to work. They don't give an error, but they don't remove the 'null'
    > > either....
    >
    > If you post the ASP/JScript code after the changes, also the HTML that this
    > produced (use View/Source in yr browser) then I'm sure someone here can
    > figure it out.
    >
    > I noticed a couple of other things:
    > 1) I'm unsure about the effect of using the \n char in server-side JScript,
    > I always use <BR> myself.
    > 2) Where you use code like:
    > var art = rs.Fields("Artist");
    > I always use:
    > var art = rs.Fields("Artist").Value;
    >
    > It could be that the 2nd point is causing yr problem: you may be getting the
    > string "null" from the field instead of the value null.
    >
    > HTH
    >
    > MC
    Jeremy Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139