Operator is not valid for type 'DBNull' and type 'Date'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    Operator is not valid for type 'DBNull' and type 'Date'

    Source Error:

    Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
    Line 174: End IF
    Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
    lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
    Line 176: If rownumber = 3 Then
    Line 177: thisfield = WhatCol.Value


    In that, the Whatcol.Value is a null value, and I am trying to return a date
    field, which is calculated MAX(j5_org.invo ice_date). The item hasn't
    shipped, so it doesn't return a shipped date.

    How can I get this code resolved to where it doesn't blow up on this?

    This code runs in traditional ASP, but does not run in ASP.NET, because of
    the error above.

    Thanks,

    SC


  • Scott M.

    #2
    Re: Operator is not valid for type 'DBNull' and type 'Date'

    If Not IsDBNull(WhatCo l.Value) then
    all your code
    End If

    <me@privacy.net > wrote in message
    news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...[color=blue]
    > Source Error:
    >
    > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
    > Line 174: End IF
    > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
    > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
    > Line 176: If rownumber = 3 Then
    > Line 177: thisfield = WhatCol.Value
    >
    >
    > In that, the Whatcol.Value is a null value, and I am trying to return a[/color]
    date[color=blue]
    > field, which is calculated MAX(j5_org.invo ice_date). The item hasn't
    > shipped, so it doesn't return a shipped date.
    >
    > How can I get this code resolved to where it doesn't blow up on this?
    >
    > This code runs in traditional ASP, but does not run in ASP.NET, because of
    > the error above.
    >
    > Thanks,
    >
    > SC
    >
    >[/color]


    Comment

    • John Saunders

      #3
      Re: Operator is not valid for type 'DBNull' and type 'Date'

      <me@privacy.net > wrote in message
      news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...[color=blue]
      > Source Error:
      >
      > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
      > Line 174: End IF
      > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
      > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
      > Line 176: If rownumber = 3 Then
      > Line 177: thisfield = WhatCol.Value
      >
      >
      > In that, the Whatcol.Value is a null value, and I am trying to return a[/color]
      date[color=blue]
      > field, which is calculated MAX(j5_org.invo ice_date). The item hasn't
      > shipped, so it doesn't return a shipped date.
      >
      > How can I get this code resolved to where it doesn't blow up on this?
      >
      > This code runs in traditional ASP, but does not run in ASP.NET, because of
      > the error above.[/color]

      Could you show us where you're getting WhatCol from?

      A lot of things run in VBScript that don't run in VB.NET. That's because
      VBScript allowed developers to get away with murder. If you really want to
      improve your coding, turn Options Strict On. You'll find many places where
      VB.NET was trying to "guess the right thing".
      --
      John Saunders
      johnwsaundersii i at hotmail


      Comment

      • Guest's Avatar

        #4
        Re: Operator is not valid for type 'DBNull' and type 'Date'

        The source data is from a SQL query that I'm running to display a web page.
        Some sample results are:


        BUSINESS AREA1 REPORTGROUP1 06-02-2004 50257.0000
        BUSINESS AREA1 REPORTGROUP2 06-03-2004 30604.0000
        BUSINESS AREA1 REPORTGROUP3 05-28-2004 2475.0000
        BUSINESS AREA1 REPORTGROUP4 06-03-2004 7763.0000
        BUSINESS AREA1 REPORTGROUP5 NULL 3.0000
        BUSINESS AREA2 REPORTGROUP1 06-04-2004
        219628.0000
        BUSINESS AREA2 REPORTGROUP2 06-04-2004
        126966.0000
        BUSINESS AREA2 REPORTGROUP3 06-03-2004 2599.0000
        BUSINESS AREA2 REPORTGROUP4 06-04-2004
        692.0000
        BUSINESS AREA2 REPORTGROUP5 06-04-2004
        21805.0000


        What it's doing is printing out the first column, then second column, and
        then it dies, when it hits the date column that's null.

        Like you said, VBScript would let you get away with some stuff, but I have
        no idea why this null in a return dataset would cause this thing to give me
        an error in dotnet. Traditional ASP didn't have a problem with it. I'm not
        totaling on the field or anything, either.




        The code to do the whole routine is here:



        <tr>
        <td><table border="9" align="center"
        style="font-family: Arial; font-size: 9pt; border: medium none"
        bordercolor="#0 00000">
        <%
        End IF
        %>

        <tr>
        <%
        'Put Headings On The Table of Field Names
        'redim sData(rs.record count,175)
        rownumber = 3
        colnumber = 0
        BeenThere = 0
        lcnt = 0
        numcols = 0
        actualcols = 0
        NrGroups = 0
        For Each WhatCol In rstemp.Fields
        If Len(WhatCol.Nam e) <> 1 Then
        thisfield = WhatCol.Name
        GroupField(lcnt ) = 0
        numcols = numcols + 1
        %>

        <td bgcolor="#FFFFF F" align="center"> <p align="center"> <font
        color="#000000" ><b><%= thisfield %></b></font></td>
        <%
        Else
        'All 1 Character Field Names are Grouping Fields
        'This sets up the grouping with hierachy determined from left to
        right in SQL
        GroupField(lcnt ) = 1
        NrGroups = NrGroups + 1
        End IF
        actualcols = actualcols + 1
        lcnt = lcnt + 1
        Next
        TBorder = "border:med ium none "
        %>

        </tr>
        <%
        'Now lets grab all the records
        rownumber = 3
        bgcolor = "white"
        Do Until rstemp.EOF
        %>

        <tr>
        <%
        lcnt = 0
        'Prepare Row for Printing
        For Each WhatCol In rstemp.Fields
        'Load data to array
        sData(rownumber , lcnt) = WhatCol.Value
        'If Data Type is currency, real or float
        If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
        GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
        WhatCol.Value
        End IF
        'Suppress Duplicates for Printing
        'Set up the first row for Grouping
        If rownumber = 3 Then
        sData(rownumber - 1, lcnt) = WhatCol.Value
        End IF
        If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
        (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
        If rownumber = 3 Then
        thisfield = WhatCol.Value
        GroupField(lcnt ) = GroupField(lcnt ) + 1
        Else
        'Added the linecount < NrGroups times 2 which not
        suppress duplicates on any field except Group Fields
        'If you need to change it back insert (thisfield =
        showblank) in place of If Statement.
        If lcnt < (NrGroups * 2) + 1 Then
        thisfield = showblank
        GroupField(lcnt ) = GroupField(lcnt ) + 1
        Else
        thisfield = WhatCol.Value
        End IF
        End IF
        Else
        thisfield = sData(rownumber , lcnt)
        GroupField(lcnt ) = 0
        End IF
        'Total Rows Field Length is 1 Character
        If Len(WhatCol.Nam e) <> 1 Then
        If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
        thisfield = FormatNumber(CD bl(thisfield), 0)
        End IF
        %>

        <td bgcolor="<%= bgcolor %>" valign="top" align="right"
        style="border: medium none"><%= thisfield %>
        <%
        End IF
        lcnt = lcnt + 1
        Next
        rstemp.MoveNext ()
        'set or reset data
        ralign = "right"
        'Change colors for every other line
        If chgcolor = 0 Then
        bgcolor = "#FFFFCC"
        chgcolor = 1
        Else
        bgcolor = "White"
        chgcolor = 0
        End IF
        'End Totals and Grouping
        lcnt = 0
        If Not rstemp.EOF Then
        For Each WhatCol In rstemp.Fields
        If Len(WhatCol.Nam e) = 1 Then
        If WhatCol.Value.T oString() <> CStr(sData(rown umber,
        lcnt)) Then
        PrintTotal(lcnt ) = lcnt
        GroupField(lcnt ) = 1
        Else
        'if rownumber<>3 then
        rowCnt(lcnt) = rowCnt(lcnt) + 1
        'end if
        GroupField(lcnt ) = 0
        End IF
        lcnt = lcnt + 1
        End IF
        Next
        End IF
        If rstemp.EOF Then
        lcnt = 0
        For Each WhatCol In rstemp.Fields
        If Len(WhatCol.Nam e) = 1 Then
        If sData(rownumber - 1, lcnt) = sData(rownumber , lcnt)
        AND CStr(sData(rown umber, lcnt)) <> "" Then
        PrintTotal(lcnt ) = lcnt
        GroupField(lcnt ) = 1
        'rowcnt(lcnt) = rowcnt(lcnt)+1
        Else
        PrintTotal(lcnt ) = NrGroups + 1
        'if rownumber<>3 then
        rowCnt(lcnt) = 0
        'end if
        GroupField(lcnt ) = 0
        End IF
        'lcnt = lcnt + 1
        End IF
        lcnt = lcnt + 1
        Next
        End IF
        lcnt = 0
        iGroup = 0
        For tcnt = 0 To NrGroups
        pcnt = NrGroups - tcnt
        If CInt(PrintTotal (pcnt)) < NrGroups AND (CInt(GroupFiel d(pcnt))
        = 1 AND CInt(rowCnt(pcn t)) > 0) Then
        GroupField(pcnt ) = 0
        'rowcnt(pcnt) = 0
        If CInt(rowCnt(pcn t)) > 0 Then
        Response.Write( "</tr><tr>")
        End IF
        For Each WhatCol In rstemp.Fields
        If Len(WhatCol.Nam e) <> 1 Then
        If CInt(rowCnt(pcn t)) < 1 AND (WhatCol.Type = 5 AND
        WhatCol.Type = 6) Then
        GrpTotal(lcnt, PrintTotal(pcnt )) = 0
        End IF
        If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type <> 5 AND
        WhatCol.Type <> 6) Then
        If lcnt = CInt((NrGroups) + PrintTotal(pcnt ))
        Then
        sTotals = CStr(sData(rown umber, lcnt))
        '& "-" & rowcnt(pcnt) & WHATCOL.TYPE
        Else
        sTotals = showblank
        End IF
        If CInt(rowCnt(pcn t)) > 0 Then
        Response.Write( "<TD style=" & TBorder & "
        ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
        "</FONT></STRONG></TD>")
        End IF
        End IF
        If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type = 5 Or
        WhatCol.Type = 6) Then
        For colcount = 0 To rowCnt(pcnt)
        atotals = sData(rownumber - colcount, lcnt)
        + atotals
        Next
        atotals = FormatNumber(CD bl(atotals), 0)
        If CInt(rowCnt(pcn t)) > 0 Then
        Response.Write( "<TD style=" & TBorder & "
        ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
        "</FONT></STRONG></TD>")
        End IF
        GrpTotal(lcnt, PrintTotal(pcnt )) = 0
        atotals = 0
        End IF
        End IF
        lcnt = lcnt + 1
        Next
        If CInt(rowCnt(pcn t)) > 0 Then
        Response.Write( "</tr><tr>")
        BeenThere = BeenThere + 1
        End IF
        rowCnt(pcnt) = 0
        'Change colors for every other line
        If chgcolor = 0 Then
        bgcolor = "#FFFFCC"
        chgcolor = 1
        Else
        bgcolor = "White"
        chgcolor = 0
        End IF
        End IF
        lcnt = 0
        Next
        rownumber = rownumber + 1
        Loop
        %>

        </td>
        </tr>
        <tr>
        <%
        'Grand Total Routine
        lcnt = 0
        col1 = 0
        If NrGroups > 0 Then
        'If any 1 character fields where defined, Grand Totals will appear
        For Each WhatCol In rstemp.Fields
        If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
        sTotal = FormatNumber(CD bl(GrandTotal(l cnt + 1, 0)), 0)
        %>

        <td bgcolor="<%= bgcolor %>" valign="top" align="right"
        style="border-left: medium none; border-right: medium none;
        border-top: medium double; border-bottom: medium none"><strong>< %= (sTotal)
        %></strong>
        <%
        sTotal = 0
        Else
        If Len(WhatCol.Nam e) <> 1 Then
        If col1 = 0 Then
        sTotal1 = "Grand Total"
        col1 = 1
        Else
        sTotal1 = showblank
        End IF
        Else
        sTotal1 = showblank
        End IF
        If Len(WhatCol.Nam e) <> 1 Then
        %>
        </td>
        <td bgcolor="<%= bgcolor %>" valign="top" align="right"
        style="border-left: medium none; border-right: medium none;
        border-top: medium double; border-bottom: medium none"><strong>< %= sTotal1
        %></strong>
        <%
        End IF
        End IF
        lcnt = lcnt + 1
        Next
        %>
        </td>
        </tr>
        <%
        End IF
        Session.Add("rp tend", Timer())
        Session.Add("rp ttime", FormatNumber(CD bl(Session("rpt end")) -
        CDbl(Session("r ptstart")), 1))
        rstemp.Close()
        rstemp = Nothing
        conntemp.Close( )
        conntemp = Nothing
        %>

        </table>
        <p><small><%
        Response.Write( "The report ran in " & Session("rpttim e") & " second(s)")
        %>
        </small></td>
        </tr>
        </table>






        "John Saunders" <johnwsaundersi ii@notcoldmail. com> wrote in message
        news:ubatuDNTEH A.1168@TK2MSFTN GP11.phx.gbl...[color=blue]
        > <me@privacy.net > wrote in message
        > news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...[color=green]
        > > Source Error:
        > >
        > > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
        > > Line 174: End IF
        > > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
        > > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
        > > Line 176: If rownumber = 3 Then
        > > Line 177: thisfield = WhatCol.Value
        > >
        > >
        > > In that, the Whatcol.Value is a null value, and I am trying to return a[/color]
        > date[color=green]
        > > field, which is calculated MAX(j5_org.invo ice_date). The item hasn't
        > > shipped, so it doesn't return a shipped date.
        > >
        > > How can I get this code resolved to where it doesn't blow up on this?
        > >
        > > This code runs in traditional ASP, but does not run in ASP.NET, because[/color][/color]
        of[color=blue][color=green]
        > > the error above.[/color]
        >
        > Could you show us where you're getting WhatCol from?
        >
        > A lot of things run in VBScript that don't run in VB.NET. That's because
        > VBScript allowed developers to get away with murder. If you really want to
        > improve your coding, turn Options Strict On. You'll find many places where
        > VB.NET was trying to "guess the right thing".
        > --
        > John Saunders
        > johnwsaundersii i at hotmail
        >
        >[/color]


        Comment

        • John Saunders

          #5
          Re: Operator is not valid for type 'DBNull' and type 'Date'

          I'll take a closer look at your code later, but the reason it doesn't let
          you get away with it is that DBNull.Value is not the same thing as
          String.Empty. It's also not the same thing as Nothing. In fact, DBNull is a
          datatype with a single value, DBNull.Value. It can't be converted to or from
          anything. It doesn't mean "blank", it means "I don't know". It's up to your
          code to decide what "I don't know" means.

          --
          John Saunders
          johnwsaundersii i at hotmail


          <me@privacy.net > wrote in message
          news:uWaWXcNTEH A.368@TK2MSFTNG P10.phx.gbl...[color=blue]
          > The source data is from a SQL query that I'm running to display a web[/color]
          page.[color=blue]
          > Some sample results are:
          >
          >
          > BUSINESS AREA1 REPORTGROUP1 06-02-2004 50257.0000
          > BUSINESS AREA1 REPORTGROUP2 06-03-2004 30604.0000
          > BUSINESS AREA1 REPORTGROUP3 05-28-2004 2475.0000
          > BUSINESS AREA1 REPORTGROUP4 06-03-2004 7763.0000
          > BUSINESS AREA1 REPORTGROUP5 NULL 3.0000
          > BUSINESS AREA2 REPORTGROUP1 06-04-2004
          > 219628.0000
          > BUSINESS AREA2 REPORTGROUP2 06-04-2004
          > 126966.0000
          > BUSINESS AREA2 REPORTGROUP3 06-03-2004 2599.0000
          > BUSINESS AREA2 REPORTGROUP4 06-04-2004
          > 692.0000
          > BUSINESS AREA2 REPORTGROUP5 06-04-2004
          > 21805.0000
          >
          >
          > What it's doing is printing out the first column, then second column, and
          > then it dies, when it hits the date column that's null.
          >
          > Like you said, VBScript would let you get away with some stuff, but I have
          > no idea why this null in a return dataset would cause this thing to give[/color]
          me[color=blue]
          > an error in dotnet. Traditional ASP didn't have a problem with it. I'm[/color]
          not[color=blue]
          > totaling on the field or anything, either.
          >
          >
          >
          >
          > The code to do the whole routine is here:
          >
          >
          >
          > <tr>
          > <td><table border="9" align="center"
          > style="font-family: Arial; font-size: 9pt; border: medium none"
          > bordercolor="#0 00000">
          > <%
          > End IF
          > %>
          >
          > <tr>
          > <%
          > 'Put Headings On The Table of Field Names
          > 'redim sData(rs.record count,175)
          > rownumber = 3
          > colnumber = 0
          > BeenThere = 0
          > lcnt = 0
          > numcols = 0
          > actualcols = 0
          > NrGroups = 0
          > For Each WhatCol In rstemp.Fields
          > If Len(WhatCol.Nam e) <> 1 Then
          > thisfield = WhatCol.Name
          > GroupField(lcnt ) = 0
          > numcols = numcols + 1
          > %>
          >
          > <td bgcolor="#FFFFF F" align="center"> <p align="center"> <font
          > color="#000000" ><b><%= thisfield %></b></font></td>
          > <%
          > Else
          > 'All 1 Character Field Names are Grouping Fields
          > 'This sets up the grouping with hierachy determined from left[/color]
          to[color=blue]
          > right in SQL
          > GroupField(lcnt ) = 1
          > NrGroups = NrGroups + 1
          > End IF
          > actualcols = actualcols + 1
          > lcnt = lcnt + 1
          > Next
          > TBorder = "border:med ium none "
          > %>
          >
          > </tr>
          > <%
          > 'Now lets grab all the records
          > rownumber = 3
          > bgcolor = "white"
          > Do Until rstemp.EOF
          > %>
          >
          > <tr>
          > <%
          > lcnt = 0
          > 'Prepare Row for Printing
          > For Each WhatCol In rstemp.Fields
          > 'Load data to array
          > sData(rownumber , lcnt) = WhatCol.Value
          > 'If Data Type is currency, real or float
          > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
          > GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
          > WhatCol.Value
          > End IF
          > 'Suppress Duplicates for Printing
          > 'Set up the first row for Grouping
          > If rownumber = 3 Then
          > sData(rownumber - 1, lcnt) = WhatCol.Value
          > End IF
          > If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
          > (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
          > If rownumber = 3 Then
          > thisfield = WhatCol.Value
          > GroupField(lcnt ) = GroupField(lcnt ) + 1
          > Else
          > 'Added the linecount < NrGroups times 2 which not
          > suppress duplicates on any field except Group Fields
          > 'If you need to change it back insert (thisfield =
          > showblank) in place of If Statement.
          > If lcnt < (NrGroups * 2) + 1 Then
          > thisfield = showblank
          > GroupField(lcnt ) = GroupField(lcnt ) + 1
          > Else
          > thisfield = WhatCol.Value
          > End IF
          > End IF
          > Else
          > thisfield = sData(rownumber , lcnt)
          > GroupField(lcnt ) = 0
          > End IF
          > 'Total Rows Field Length is 1 Character
          > If Len(WhatCol.Nam e) <> 1 Then
          > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
          > thisfield = FormatNumber(CD bl(thisfield), 0)
          > End IF
          > %>
          >
          > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
          > style="border: medium none"><%= thisfield %>
          > <%
          > End IF
          > lcnt = lcnt + 1
          > Next
          > rstemp.MoveNext ()
          > 'set or reset data
          > ralign = "right"
          > 'Change colors for every other line
          > If chgcolor = 0 Then
          > bgcolor = "#FFFFCC"
          > chgcolor = 1
          > Else
          > bgcolor = "White"
          > chgcolor = 0
          > End IF
          > 'End Totals and Grouping
          > lcnt = 0
          > If Not rstemp.EOF Then
          > For Each WhatCol In rstemp.Fields
          > If Len(WhatCol.Nam e) = 1 Then
          > If WhatCol.Value.T oString() <> CStr(sData(rown umber,
          > lcnt)) Then
          > PrintTotal(lcnt ) = lcnt
          > GroupField(lcnt ) = 1
          > Else
          > 'if rownumber<>3 then
          > rowCnt(lcnt) = rowCnt(lcnt) + 1
          > 'end if
          > GroupField(lcnt ) = 0
          > End IF
          > lcnt = lcnt + 1
          > End IF
          > Next
          > End IF
          > If rstemp.EOF Then
          > lcnt = 0
          > For Each WhatCol In rstemp.Fields
          > If Len(WhatCol.Nam e) = 1 Then
          > If sData(rownumber - 1, lcnt) = sData(rownumber , lcnt)
          > AND CStr(sData(rown umber, lcnt)) <> "" Then
          > PrintTotal(lcnt ) = lcnt
          > GroupField(lcnt ) = 1
          > 'rowcnt(lcnt) = rowcnt(lcnt)+1
          > Else
          > PrintTotal(lcnt ) = NrGroups + 1
          > 'if rownumber<>3 then
          > rowCnt(lcnt) = 0
          > 'end if
          > GroupField(lcnt ) = 0
          > End IF
          > 'lcnt = lcnt + 1
          > End IF
          > lcnt = lcnt + 1
          > Next
          > End IF
          > lcnt = 0
          > iGroup = 0
          > For tcnt = 0 To NrGroups
          > pcnt = NrGroups - tcnt
          > If CInt(PrintTotal (pcnt)) < NrGroups AND[/color]
          (CInt(GroupFiel d(pcnt))[color=blue]
          > = 1 AND CInt(rowCnt(pcn t)) > 0) Then
          > GroupField(pcnt ) = 0
          > 'rowcnt(pcnt) = 0
          > If CInt(rowCnt(pcn t)) > 0 Then
          > Response.Write( "</tr><tr>")
          > End IF
          > For Each WhatCol In rstemp.Fields
          > If Len(WhatCol.Nam e) <> 1 Then
          > If CInt(rowCnt(pcn t)) < 1 AND (WhatCol.Type = 5[/color]
          AND[color=blue]
          > WhatCol.Type = 6) Then
          > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
          > End IF
          > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type <> 5[/color]
          AND[color=blue]
          > WhatCol.Type <> 6) Then
          > If lcnt = CInt((NrGroups) + PrintTotal(pcnt ))
          > Then
          > sTotals = CStr(sData(rown umber, lcnt))
          > '& "-" & rowcnt(pcnt) & WHATCOL.TYPE
          > Else
          > sTotals = showblank
          > End IF
          > If CInt(rowCnt(pcn t)) > 0 Then
          > Response.Write( "<TD style=" & TBorder & "
          > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
          > "</FONT></STRONG></TD>")
          > End IF
          > End IF
          > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type = 5 Or
          > WhatCol.Type = 6) Then
          > For colcount = 0 To rowCnt(pcnt)
          > atotals = sData(rownumber - colcount,[/color]
          lcnt)[color=blue]
          > + atotals
          > Next
          > atotals = FormatNumber(CD bl(atotals), 0)
          > If CInt(rowCnt(pcn t)) > 0 Then
          > Response.Write( "<TD style=" & TBorder & "
          > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
          > "</FONT></STRONG></TD>")
          > End IF
          > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
          > atotals = 0
          > End IF
          > End IF
          > lcnt = lcnt + 1
          > Next
          > If CInt(rowCnt(pcn t)) > 0 Then
          > Response.Write( "</tr><tr>")
          > BeenThere = BeenThere + 1
          > End IF
          > rowCnt(pcnt) = 0
          > 'Change colors for every other line
          > If chgcolor = 0 Then
          > bgcolor = "#FFFFCC"
          > chgcolor = 1
          > Else
          > bgcolor = "White"
          > chgcolor = 0
          > End IF
          > End IF
          > lcnt = 0
          > Next
          > rownumber = rownumber + 1
          > Loop
          > %>
          >
          > </td>
          > </tr>
          > <tr>
          > <%
          > 'Grand Total Routine
          > lcnt = 0
          > col1 = 0
          > If NrGroups > 0 Then
          > 'If any 1 character fields where defined, Grand Totals will appear
          > For Each WhatCol In rstemp.Fields
          > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
          > sTotal = FormatNumber(CD bl(GrandTotal(l cnt + 1, 0)), 0)
          > %>
          >
          > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
          > style="border-left: medium none; border-right: medium none;
          > border-top: medium double; border-bottom: medium none"><strong>< %=[/color]
          (sTotal)[color=blue]
          > %></strong>
          > <%
          > sTotal = 0
          > Else
          > If Len(WhatCol.Nam e) <> 1 Then
          > If col1 = 0 Then
          > sTotal1 = "Grand Total"
          > col1 = 1
          > Else
          > sTotal1 = showblank
          > End IF
          > Else
          > sTotal1 = showblank
          > End IF
          > If Len(WhatCol.Nam e) <> 1 Then
          > %>
          > </td>
          > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
          > style="border-left: medium none; border-right: medium none;
          > border-top: medium double; border-bottom: medium none"><strong>< %= sTotal1
          > %></strong>
          > <%
          > End IF
          > End IF
          > lcnt = lcnt + 1
          > Next
          > %>
          > </td>
          > </tr>
          > <%
          > End IF
          > Session.Add("rp tend", Timer())
          > Session.Add("rp ttime", FormatNumber(CD bl(Session("rpt end")) -
          > CDbl(Session("r ptstart")), 1))
          > rstemp.Close()
          > rstemp = Nothing
          > conntemp.Close( )
          > conntemp = Nothing
          > %>
          >
          > </table>
          > <p><small><%
          > Response.Write( "The report ran in " & Session("rpttim e") & "[/color]
          second(s)")[color=blue]
          > %>
          > </small></td>
          > </tr>
          > </table>
          >
          >
          >
          >
          >
          >
          > "John Saunders" <johnwsaundersi ii@notcoldmail. com> wrote in message
          > news:ubatuDNTEH A.1168@TK2MSFTN GP11.phx.gbl...[color=green]
          > > <me@privacy.net > wrote in message
          > > news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...[color=darkred]
          > > > Source Error:
          > > >
          > > > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
          > > > Line 174: End IF
          > > > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
          > > > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
          > > > Line 176: If rownumber = 3 Then
          > > > Line 177: thisfield = WhatCol.Value
          > > >
          > > >
          > > > In that, the Whatcol.Value is a null value, and I am trying to return[/color][/color][/color]
          a[color=blue][color=green]
          > > date[color=darkred]
          > > > field, which is calculated MAX(j5_org.invo ice_date). The item[/color][/color][/color]
          hasn't[color=blue][color=green][color=darkred]
          > > > shipped, so it doesn't return a shipped date.
          > > >
          > > > How can I get this code resolved to where it doesn't blow up on this?
          > > >
          > > > This code runs in traditional ASP, but does not run in ASP.NET,[/color][/color][/color]
          because[color=blue]
          > of[color=green][color=darkred]
          > > > the error above.[/color]
          > >
          > > Could you show us where you're getting WhatCol from?
          > >
          > > A lot of things run in VBScript that don't run in VB.NET. That's because
          > > VBScript allowed developers to get away with murder. If you really want[/color][/color]
          to[color=blue][color=green]
          > > improve your coding, turn Options Strict On. You'll find many places[/color][/color]
          where[color=blue][color=green]
          > > VB.NET was trying to "guess the right thing".
          > > --
          > > John Saunders
          > > johnwsaundersii i at hotmail
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Scott M.

            #6
            Re: Operator is not valid for type 'DBNull' and type 'Date'

            You really should leave this as a classic ASP page until you are ready to
            fully convert it to ASP .NET. You are still using all the classic ASP
            methodologies in an ASP .NET architecture. You'll find that using a
            DataGrid and binding it to the data returned from your query is much easier
            than all the inline coding that you are doing.

            And, from my earlier post, if you check a field for DBNull (either by
            comparing against DBNull.Value or using IsDBNull(field) ) before you attempt
            to use it, you're problem will be solved.


            <me@privacy.net > wrote in message
            news:uWaWXcNTEH A.368@TK2MSFTNG P10.phx.gbl...[color=blue]
            > The source data is from a SQL query that I'm running to display a web[/color]
            page.[color=blue]
            > Some sample results are:
            >
            >
            > BUSINESS AREA1 REPORTGROUP1 06-02-2004 50257.0000
            > BUSINESS AREA1 REPORTGROUP2 06-03-2004 30604.0000
            > BUSINESS AREA1 REPORTGROUP3 05-28-2004 2475.0000
            > BUSINESS AREA1 REPORTGROUP4 06-03-2004 7763.0000
            > BUSINESS AREA1 REPORTGROUP5 NULL 3.0000
            > BUSINESS AREA2 REPORTGROUP1 06-04-2004
            > 219628.0000
            > BUSINESS AREA2 REPORTGROUP2 06-04-2004
            > 126966.0000
            > BUSINESS AREA2 REPORTGROUP3 06-03-2004 2599.0000
            > BUSINESS AREA2 REPORTGROUP4 06-04-2004
            > 692.0000
            > BUSINESS AREA2 REPORTGROUP5 06-04-2004
            > 21805.0000
            >
            >
            > What it's doing is printing out the first column, then second column, and
            > then it dies, when it hits the date column that's null.
            >
            > Like you said, VBScript would let you get away with some stuff, but I have
            > no idea why this null in a return dataset would cause this thing to give[/color]
            me[color=blue]
            > an error in dotnet. Traditional ASP didn't have a problem with it. I'm[/color]
            not[color=blue]
            > totaling on the field or anything, either.
            >
            >
            >
            >
            > The code to do the whole routine is here:
            >
            >
            >
            > <tr>
            > <td><table border="9" align="center"
            > style="font-family: Arial; font-size: 9pt; border: medium none"
            > bordercolor="#0 00000">
            > <%
            > End IF
            > %>
            >
            > <tr>
            > <%
            > 'Put Headings On The Table of Field Names
            > 'redim sData(rs.record count,175)
            > rownumber = 3
            > colnumber = 0
            > BeenThere = 0
            > lcnt = 0
            > numcols = 0
            > actualcols = 0
            > NrGroups = 0
            > For Each WhatCol In rstemp.Fields
            > If Len(WhatCol.Nam e) <> 1 Then
            > thisfield = WhatCol.Name
            > GroupField(lcnt ) = 0
            > numcols = numcols + 1
            > %>
            >
            > <td bgcolor="#FFFFF F" align="center"> <p align="center"> <font
            > color="#000000" ><b><%= thisfield %></b></font></td>
            > <%
            > Else
            > 'All 1 Character Field Names are Grouping Fields
            > 'This sets up the grouping with hierachy determined from left[/color]
            to[color=blue]
            > right in SQL
            > GroupField(lcnt ) = 1
            > NrGroups = NrGroups + 1
            > End IF
            > actualcols = actualcols + 1
            > lcnt = lcnt + 1
            > Next
            > TBorder = "border:med ium none "
            > %>
            >
            > </tr>
            > <%
            > 'Now lets grab all the records
            > rownumber = 3
            > bgcolor = "white"
            > Do Until rstemp.EOF
            > %>
            >
            > <tr>
            > <%
            > lcnt = 0
            > 'Prepare Row for Printing
            > For Each WhatCol In rstemp.Fields
            > 'Load data to array
            > sData(rownumber , lcnt) = WhatCol.Value
            > 'If Data Type is currency, real or float
            > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
            > GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
            > WhatCol.Value
            > End IF
            > 'Suppress Duplicates for Printing
            > 'Set up the first row for Grouping
            > If rownumber = 3 Then
            > sData(rownumber - 1, lcnt) = WhatCol.Value
            > End IF
            > If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
            > (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
            > If rownumber = 3 Then
            > thisfield = WhatCol.Value
            > GroupField(lcnt ) = GroupField(lcnt ) + 1
            > Else
            > 'Added the linecount < NrGroups times 2 which not
            > suppress duplicates on any field except Group Fields
            > 'If you need to change it back insert (thisfield =
            > showblank) in place of If Statement.
            > If lcnt < (NrGroups * 2) + 1 Then
            > thisfield = showblank
            > GroupField(lcnt ) = GroupField(lcnt ) + 1
            > Else
            > thisfield = WhatCol.Value
            > End IF
            > End IF
            > Else
            > thisfield = sData(rownumber , lcnt)
            > GroupField(lcnt ) = 0
            > End IF
            > 'Total Rows Field Length is 1 Character
            > If Len(WhatCol.Nam e) <> 1 Then
            > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
            > thisfield = FormatNumber(CD bl(thisfield), 0)
            > End IF
            > %>
            >
            > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
            > style="border: medium none"><%= thisfield %>
            > <%
            > End IF
            > lcnt = lcnt + 1
            > Next
            > rstemp.MoveNext ()
            > 'set or reset data
            > ralign = "right"
            > 'Change colors for every other line
            > If chgcolor = 0 Then
            > bgcolor = "#FFFFCC"
            > chgcolor = 1
            > Else
            > bgcolor = "White"
            > chgcolor = 0
            > End IF
            > 'End Totals and Grouping
            > lcnt = 0
            > If Not rstemp.EOF Then
            > For Each WhatCol In rstemp.Fields
            > If Len(WhatCol.Nam e) = 1 Then
            > If WhatCol.Value.T oString() <> CStr(sData(rown umber,
            > lcnt)) Then
            > PrintTotal(lcnt ) = lcnt
            > GroupField(lcnt ) = 1
            > Else
            > 'if rownumber<>3 then
            > rowCnt(lcnt) = rowCnt(lcnt) + 1
            > 'end if
            > GroupField(lcnt ) = 0
            > End IF
            > lcnt = lcnt + 1
            > End IF
            > Next
            > End IF
            > If rstemp.EOF Then
            > lcnt = 0
            > For Each WhatCol In rstemp.Fields
            > If Len(WhatCol.Nam e) = 1 Then
            > If sData(rownumber - 1, lcnt) = sData(rownumber , lcnt)
            > AND CStr(sData(rown umber, lcnt)) <> "" Then
            > PrintTotal(lcnt ) = lcnt
            > GroupField(lcnt ) = 1
            > 'rowcnt(lcnt) = rowcnt(lcnt)+1
            > Else
            > PrintTotal(lcnt ) = NrGroups + 1
            > 'if rownumber<>3 then
            > rowCnt(lcnt) = 0
            > 'end if
            > GroupField(lcnt ) = 0
            > End IF
            > 'lcnt = lcnt + 1
            > End IF
            > lcnt = lcnt + 1
            > Next
            > End IF
            > lcnt = 0
            > iGroup = 0
            > For tcnt = 0 To NrGroups
            > pcnt = NrGroups - tcnt
            > If CInt(PrintTotal (pcnt)) < NrGroups AND[/color]
            (CInt(GroupFiel d(pcnt))[color=blue]
            > = 1 AND CInt(rowCnt(pcn t)) > 0) Then
            > GroupField(pcnt ) = 0
            > 'rowcnt(pcnt) = 0
            > If CInt(rowCnt(pcn t)) > 0 Then
            > Response.Write( "</tr><tr>")
            > End IF
            > For Each WhatCol In rstemp.Fields
            > If Len(WhatCol.Nam e) <> 1 Then
            > If CInt(rowCnt(pcn t)) < 1 AND (WhatCol.Type = 5[/color]
            AND[color=blue]
            > WhatCol.Type = 6) Then
            > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
            > End IF
            > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type <> 5[/color]
            AND[color=blue]
            > WhatCol.Type <> 6) Then
            > If lcnt = CInt((NrGroups) + PrintTotal(pcnt ))
            > Then
            > sTotals = CStr(sData(rown umber, lcnt))
            > '& "-" & rowcnt(pcnt) & WHATCOL.TYPE
            > Else
            > sTotals = showblank
            > End IF
            > If CInt(rowCnt(pcn t)) > 0 Then
            > Response.Write( "<TD style=" & TBorder & "
            > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
            > "</FONT></STRONG></TD>")
            > End IF
            > End IF
            > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type = 5 Or
            > WhatCol.Type = 6) Then
            > For colcount = 0 To rowCnt(pcnt)
            > atotals = sData(rownumber - colcount,[/color]
            lcnt)[color=blue]
            > + atotals
            > Next
            > atotals = FormatNumber(CD bl(atotals), 0)
            > If CInt(rowCnt(pcn t)) > 0 Then
            > Response.Write( "<TD style=" & TBorder & "
            > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
            > "</FONT></STRONG></TD>")
            > End IF
            > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
            > atotals = 0
            > End IF
            > End IF
            > lcnt = lcnt + 1
            > Next
            > If CInt(rowCnt(pcn t)) > 0 Then
            > Response.Write( "</tr><tr>")
            > BeenThere = BeenThere + 1
            > End IF
            > rowCnt(pcnt) = 0
            > 'Change colors for every other line
            > If chgcolor = 0 Then
            > bgcolor = "#FFFFCC"
            > chgcolor = 1
            > Else
            > bgcolor = "White"
            > chgcolor = 0
            > End IF
            > End IF
            > lcnt = 0
            > Next
            > rownumber = rownumber + 1
            > Loop
            > %>
            >
            > </td>
            > </tr>
            > <tr>
            > <%
            > 'Grand Total Routine
            > lcnt = 0
            > col1 = 0
            > If NrGroups > 0 Then
            > 'If any 1 character fields where defined, Grand Totals will appear
            > For Each WhatCol In rstemp.Fields
            > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
            > sTotal = FormatNumber(CD bl(GrandTotal(l cnt + 1, 0)), 0)
            > %>
            >
            > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
            > style="border-left: medium none; border-right: medium none;
            > border-top: medium double; border-bottom: medium none"><strong>< %=[/color]
            (sTotal)[color=blue]
            > %></strong>
            > <%
            > sTotal = 0
            > Else
            > If Len(WhatCol.Nam e) <> 1 Then
            > If col1 = 0 Then
            > sTotal1 = "Grand Total"
            > col1 = 1
            > Else
            > sTotal1 = showblank
            > End IF
            > Else
            > sTotal1 = showblank
            > End IF
            > If Len(WhatCol.Nam e) <> 1 Then
            > %>
            > </td>
            > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
            > style="border-left: medium none; border-right: medium none;
            > border-top: medium double; border-bottom: medium none"><strong>< %= sTotal1
            > %></strong>
            > <%
            > End IF
            > End IF
            > lcnt = lcnt + 1
            > Next
            > %>
            > </td>
            > </tr>
            > <%
            > End IF
            > Session.Add("rp tend", Timer())
            > Session.Add("rp ttime", FormatNumber(CD bl(Session("rpt end")) -
            > CDbl(Session("r ptstart")), 1))
            > rstemp.Close()
            > rstemp = Nothing
            > conntemp.Close( )
            > conntemp = Nothing
            > %>
            >
            > </table>
            > <p><small><%
            > Response.Write( "The report ran in " & Session("rpttim e") & "[/color]
            second(s)")[color=blue]
            > %>
            > </small></td>
            > </tr>
            > </table>
            >
            >
            >
            >
            >
            >
            > "John Saunders" <johnwsaundersi ii@notcoldmail. com> wrote in message
            > news:ubatuDNTEH A.1168@TK2MSFTN GP11.phx.gbl...[color=green]
            > > <me@privacy.net > wrote in message
            > > news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...[color=darkred]
            > > > Source Error:
            > > >
            > > > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
            > > > Line 174: End IF
            > > > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber - 1,
            > > > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
            > > > Line 176: If rownumber = 3 Then
            > > > Line 177: thisfield = WhatCol.Value
            > > >
            > > >
            > > > In that, the Whatcol.Value is a null value, and I am trying to return[/color][/color][/color]
            a[color=blue][color=green]
            > > date[color=darkred]
            > > > field, which is calculated MAX(j5_org.invo ice_date). The item[/color][/color][/color]
            hasn't[color=blue][color=green][color=darkred]
            > > > shipped, so it doesn't return a shipped date.
            > > >
            > > > How can I get this code resolved to where it doesn't blow up on this?
            > > >
            > > > This code runs in traditional ASP, but does not run in ASP.NET,[/color][/color][/color]
            because[color=blue]
            > of[color=green][color=darkred]
            > > > the error above.[/color]
            > >
            > > Could you show us where you're getting WhatCol from?
            > >
            > > A lot of things run in VBScript that don't run in VB.NET. That's because
            > > VBScript allowed developers to get away with murder. If you really want[/color][/color]
            to[color=blue][color=green]
            > > improve your coding, turn Options Strict On. You'll find many places[/color][/color]
            where[color=blue][color=green]
            > > VB.NET was trying to "guess the right thing".
            > > --
            > > John Saunders
            > > johnwsaundersii i at hotmail
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Guest's Avatar

              #7
              Re: Operator is not valid for type 'DBNull' and type 'Date'

              <<You really should leave this as a classic ASP page until you are ready to
              fully convert it to ASP .NET. You are still using all the classic ASP
              methodologies in an ASP .NET architecture. You'll find that using a
              DataGrid and binding it to the data returned from your query is much easier
              than all the inline coding that you are doing.>>

              We had started doing exactly what you're describing. However, we
              encountered a problem for which I have been unable to find a solution. That
              problem was saving to Excel. Lots of the reports we create, our users will
              save them to excel and work with them, in terms of developing forecasts,
              etc. With the controls on screen, we found that we had a little better than
              a 50% failure rate in either opening the file in excel, or if the report was
              a large one, it'd prompt you a number of times for a user id & password and
              wouldn't ever produce the excel sheet. The problem in the opening the file
              in excel was due directly to the controls being on the screen. Since we
              have a number of variables that go in to producing the reports, it was
              impractical to try to convert a 2nd page that'd load the report in a format
              that COULD be saved and opened in Excel.

              I posted the problem I had with both of them numerous times in one of the
              framework.aspne t groups, and was never able to find a satisfactory
              resolution. At that point, we decided to just take our traditional asp
              application, and convert it to dotnet, when we found that a number of the
              reports we generated all would save & open in Excel, when we created them
              with the converted report writer.

              <<And, from my earlier post, if you check a field for DBNull (either by
              comparing against DBNull.Value or using IsDBNull(field) ) before you attempt
              to use it, you're problem will be solved.>>

              I've tried this, but evidently, I did not have the check in the right place.

              I had:

              If Not IsDBNull(WhatCo l.Value) then
              If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
              (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
              If rownumber = 3 Then
              thisfield = WhatCol.Value
              GroupField(lcnt ) = GroupField(lcnt ) + 1
              Else
              'Added the linecount < NrGroups times 2 which not
              suppress duplicates on any field except Group Fields
              'If you need to change it back insert (thisfield =
              showblank) in place of If Statement.
              If lcnt < (NrGroups * 2) + 1 Then
              thisfield = showblank
              GroupField(lcnt ) = GroupField(lcnt ) + 1
              Else
              thisfield = WhatCol.Value
              End IF
              End IF
              Else
              thisfield = sData(rownumber , lcnt)
              GroupField(lcnt ) = 0
              End IF
              Else
              thisfield = sData(rownumber ,lcnt)
              GroupField(lcnt ) = 0
              End if

              It still gave me the dbnull error.

              SC



              [color=blue]
              >
              >
              > <me@privacy.net > wrote in message
              > news:uWaWXcNTEH A.368@TK2MSFTNG P10.phx.gbl...[color=green]
              > > The source data is from a SQL query that I'm running to display a web[/color]
              > page.[color=green]
              > > Some sample results are:
              > >
              > >
              > > BUSINESS AREA1 REPORTGROUP1 06-02-2004[/color][/color]
              50257.0000[color=blue][color=green]
              > > BUSINESS AREA1 REPORTGROUP2 06-03-2004 30604.0000
              > > BUSINESS AREA1 REPORTGROUP3 05-28-2004[/color][/color]
              2475.0000[color=blue][color=green]
              > > BUSINESS AREA1 REPORTGROUP4 06-03-2004 7763.0000
              > > BUSINESS AREA1 REPORTGROUP5 NULL 3.0000
              > > BUSINESS AREA2 REPORTGROUP1 06-04-2004
              > > 219628.0000
              > > BUSINESS AREA2 REPORTGROUP2 06-04-2004
              > > 126966.0000
              > > BUSINESS AREA2 REPORTGROUP3 06-03-2004[/color][/color]
              2599.0000[color=blue][color=green]
              > > BUSINESS AREA2 REPORTGROUP4 06-04-2004
              > > 692.0000
              > > BUSINESS AREA2 REPORTGROUP5 06-04-2004
              > > 21805.0000
              > >
              > >
              > > What it's doing is printing out the first column, then second column,[/color][/color]
              and[color=blue][color=green]
              > > then it dies, when it hits the date column that's null.
              > >
              > > Like you said, VBScript would let you get away with some stuff, but I[/color][/color]
              have[color=blue][color=green]
              > > no idea why this null in a return dataset would cause this thing to give[/color]
              > me[color=green]
              > > an error in dotnet. Traditional ASP didn't have a problem with it. I'm[/color]
              > not[color=green]
              > > totaling on the field or anything, either.
              > >
              > >
              > >
              > >
              > > The code to do the whole routine is here:
              > >
              > >
              > >
              > > <tr>
              > > <td><table border="9" align="center"
              > > style="font-family: Arial; font-size: 9pt; border: medium none"
              > > bordercolor="#0 00000">
              > > <%
              > > End IF
              > > %>
              > >
              > > <tr>
              > > <%
              > > 'Put Headings On The Table of Field Names
              > > 'redim sData(rs.record count,175)
              > > rownumber = 3
              > > colnumber = 0
              > > BeenThere = 0
              > > lcnt = 0
              > > numcols = 0
              > > actualcols = 0
              > > NrGroups = 0
              > > For Each WhatCol In rstemp.Fields
              > > If Len(WhatCol.Nam e) <> 1 Then
              > > thisfield = WhatCol.Name
              > > GroupField(lcnt ) = 0
              > > numcols = numcols + 1
              > > %>
              > >
              > > <td bgcolor="#FFFFF F" align="center"> <p align="center"> <font
              > > color="#000000" ><b><%= thisfield %></b></font></td>
              > > <%
              > > Else
              > > 'All 1 Character Field Names are Grouping Fields
              > > 'This sets up the grouping with hierachy determined from[/color][/color]
              left[color=blue]
              > to[color=green]
              > > right in SQL
              > > GroupField(lcnt ) = 1
              > > NrGroups = NrGroups + 1
              > > End IF
              > > actualcols = actualcols + 1
              > > lcnt = lcnt + 1
              > > Next
              > > TBorder = "border:med ium none "
              > > %>
              > >
              > > </tr>
              > > <%
              > > 'Now lets grab all the records
              > > rownumber = 3
              > > bgcolor = "white"
              > > Do Until rstemp.EOF
              > > %>
              > >
              > > <tr>
              > > <%
              > > lcnt = 0
              > > 'Prepare Row for Printing
              > > For Each WhatCol In rstemp.Fields
              > > 'Load data to array
              > > sData(rownumber , lcnt) = WhatCol.Value
              > > 'If Data Type is currency, real or float
              > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
              > > GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
              > > WhatCol.Value
              > > End IF
              > > 'Suppress Duplicates for Printing
              > > 'Set up the first row for Grouping
              > > If rownumber = 3 Then
              > > sData(rownumber - 1, lcnt) = WhatCol.Value
              > > End IF
              > > If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
              > > (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
              > > If rownumber = 3 Then
              > > thisfield = WhatCol.Value
              > > GroupField(lcnt ) = GroupField(lcnt ) + 1
              > > Else
              > > 'Added the linecount < NrGroups times 2 which not
              > > suppress duplicates on any field except Group Fields
              > > 'If you need to change it back insert (thisfield =
              > > showblank) in place of If Statement.
              > > If lcnt < (NrGroups * 2) + 1 Then
              > > thisfield = showblank
              > > GroupField(lcnt ) = GroupField(lcnt ) + 1
              > > Else
              > > thisfield = WhatCol.Value
              > > End IF
              > > End IF
              > > Else
              > > thisfield = sData(rownumber , lcnt)
              > > GroupField(lcnt ) = 0
              > > End IF
              > > 'Total Rows Field Length is 1 Character
              > > If Len(WhatCol.Nam e) <> 1 Then
              > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
              > > thisfield = FormatNumber(CD bl(thisfield), 0)
              > > End IF
              > > %>
              > >
              > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
              > > style="border: medium none"><%= thisfield %>
              > > <%
              > > End IF
              > > lcnt = lcnt + 1
              > > Next
              > > rstemp.MoveNext ()
              > > 'set or reset data
              > > ralign = "right"
              > > 'Change colors for every other line
              > > If chgcolor = 0 Then
              > > bgcolor = "#FFFFCC"
              > > chgcolor = 1
              > > Else
              > > bgcolor = "White"
              > > chgcolor = 0
              > > End IF
              > > 'End Totals and Grouping
              > > lcnt = 0
              > > If Not rstemp.EOF Then
              > > For Each WhatCol In rstemp.Fields
              > > If Len(WhatCol.Nam e) = 1 Then
              > > If WhatCol.Value.T oString() <> CStr(sData(rown umber,
              > > lcnt)) Then
              > > PrintTotal(lcnt ) = lcnt
              > > GroupField(lcnt ) = 1
              > > Else
              > > 'if rownumber<>3 then
              > > rowCnt(lcnt) = rowCnt(lcnt) + 1
              > > 'end if
              > > GroupField(lcnt ) = 0
              > > End IF
              > > lcnt = lcnt + 1
              > > End IF
              > > Next
              > > End IF
              > > If rstemp.EOF Then
              > > lcnt = 0
              > > For Each WhatCol In rstemp.Fields
              > > If Len(WhatCol.Nam e) = 1 Then
              > > If sData(rownumber - 1, lcnt) = sData(rownumber ,[/color][/color]
              lcnt)[color=blue][color=green]
              > > AND CStr(sData(rown umber, lcnt)) <> "" Then
              > > PrintTotal(lcnt ) = lcnt
              > > GroupField(lcnt ) = 1
              > > 'rowcnt(lcnt) = rowcnt(lcnt)+1
              > > Else
              > > PrintTotal(lcnt ) = NrGroups + 1
              > > 'if rownumber<>3 then
              > > rowCnt(lcnt) = 0
              > > 'end if
              > > GroupField(lcnt ) = 0
              > > End IF
              > > 'lcnt = lcnt + 1
              > > End IF
              > > lcnt = lcnt + 1
              > > Next
              > > End IF
              > > lcnt = 0
              > > iGroup = 0
              > > For tcnt = 0 To NrGroups
              > > pcnt = NrGroups - tcnt
              > > If CInt(PrintTotal (pcnt)) < NrGroups AND[/color]
              > (CInt(GroupFiel d(pcnt))[color=green]
              > > = 1 AND CInt(rowCnt(pcn t)) > 0) Then
              > > GroupField(pcnt ) = 0
              > > 'rowcnt(pcnt) = 0
              > > If CInt(rowCnt(pcn t)) > 0 Then
              > > Response.Write( "</tr><tr>")
              > > End IF
              > > For Each WhatCol In rstemp.Fields
              > > If Len(WhatCol.Nam e) <> 1 Then
              > > If CInt(rowCnt(pcn t)) < 1 AND (WhatCol.Type = 5[/color]
              > AND[color=green]
              > > WhatCol.Type = 6) Then
              > > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
              > > End IF
              > > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type <> 5[/color]
              > AND[color=green]
              > > WhatCol.Type <> 6) Then
              > > If lcnt = CInt((NrGroups) +[/color][/color]
              PrintTotal(pcnt ))[color=blue][color=green]
              > > Then
              > > sTotals = CStr(sData(rown umber, lcnt))
              > > '& "-" & rowcnt(pcnt) & WHATCOL.TYPE
              > > Else
              > > sTotals = showblank
              > > End IF
              > > If CInt(rowCnt(pcn t)) > 0 Then
              > > Response.Write( "<TD style=" & TBorder &[/color][/color]
              "[color=blue][color=green]
              > > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
              > > "</FONT></STRONG></TD>")
              > > End IF
              > > End IF
              > > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type = 5[/color][/color]
              Or[color=blue][color=green]
              > > WhatCol.Type = 6) Then
              > > For colcount = 0 To rowCnt(pcnt)
              > > atotals = sData(rownumber - colcount,[/color]
              > lcnt)[color=green]
              > > + atotals
              > > Next
              > > atotals = FormatNumber(CD bl(atotals), 0)
              > > If CInt(rowCnt(pcn t)) > 0 Then
              > > Response.Write( "<TD style=" & TBorder &[/color][/color]
              "[color=blue][color=green]
              > > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
              > > "</FONT></STRONG></TD>")
              > > End IF
              > > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
              > > atotals = 0
              > > End IF
              > > End IF
              > > lcnt = lcnt + 1
              > > Next
              > > If CInt(rowCnt(pcn t)) > 0 Then
              > > Response.Write( "</tr><tr>")
              > > BeenThere = BeenThere + 1
              > > End IF
              > > rowCnt(pcnt) = 0
              > > 'Change colors for every other line
              > > If chgcolor = 0 Then
              > > bgcolor = "#FFFFCC"
              > > chgcolor = 1
              > > Else
              > > bgcolor = "White"
              > > chgcolor = 0
              > > End IF
              > > End IF
              > > lcnt = 0
              > > Next
              > > rownumber = rownumber + 1
              > > Loop
              > > %>
              > >
              > > </td>
              > > </tr>
              > > <tr>
              > > <%
              > > 'Grand Total Routine
              > > lcnt = 0
              > > col1 = 0
              > > If NrGroups > 0 Then
              > > 'If any 1 character fields where defined, Grand Totals will[/color][/color]
              appear[color=blue][color=green]
              > > For Each WhatCol In rstemp.Fields
              > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
              > > sTotal = FormatNumber(CD bl(GrandTotal(l cnt + 1, 0)), 0)
              > > %>
              > >
              > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
              > > style="border-left: medium none; border-right: medium none;
              > > border-top: medium double; border-bottom: medium none"><strong>< %=[/color]
              > (sTotal)[color=green]
              > > %></strong>
              > > <%
              > > sTotal = 0
              > > Else
              > > If Len(WhatCol.Nam e) <> 1 Then
              > > If col1 = 0 Then
              > > sTotal1 = "Grand Total"
              > > col1 = 1
              > > Else
              > > sTotal1 = showblank
              > > End IF
              > > Else
              > > sTotal1 = showblank
              > > End IF
              > > If Len(WhatCol.Nam e) <> 1 Then
              > > %>
              > > </td>
              > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
              > > style="border-left: medium none; border-right: medium none;
              > > border-top: medium double; border-bottom: medium none"><strong>< %=[/color][/color]
              sTotal1[color=blue][color=green]
              > > %></strong>
              > > <%
              > > End IF
              > > End IF
              > > lcnt = lcnt + 1
              > > Next
              > > %>
              > > </td>
              > > </tr>
              > > <%
              > > End IF
              > > Session.Add("rp tend", Timer())
              > > Session.Add("rp ttime", FormatNumber(CD bl(Session("rpt end")) -
              > > CDbl(Session("r ptstart")), 1))
              > > rstemp.Close()
              > > rstemp = Nothing
              > > conntemp.Close( )
              > > conntemp = Nothing
              > > %>
              > >
              > > </table>
              > > <p><small><%
              > > Response.Write( "The report ran in " & Session("rpttim e") & "[/color]
              > second(s)")[color=green]
              > > %>
              > > </small></td>
              > > </tr>
              > > </table>
              > >
              > >
              > >
              > >
              > >
              > >
              > > "John Saunders" <johnwsaundersi ii@notcoldmail. com> wrote in message
              > > news:ubatuDNTEH A.1168@TK2MSFTN GP11.phx.gbl...[color=darkred]
              > > > <me@privacy.net > wrote in message
              > > > news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...
              > > > > Source Error:
              > > > >
              > > > > Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
              > > > > Line 174: End IF
              > > > > Line 175: If (sData(rownumbe r, lcnt) = sData(rownumber -[/color][/color][/color]
              1,[color=blue][color=green][color=darkred]
              > > > > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
              > > > > Line 176: If rownumber = 3 Then
              > > > > Line 177: thisfield = WhatCol.Value
              > > > >
              > > > >
              > > > > In that, the Whatcol.Value is a null value, and I am trying to[/color][/color][/color]
              return[color=blue]
              > a[color=green][color=darkred]
              > > > date
              > > > > field, which is calculated MAX(j5_org.invo ice_date). The item[/color][/color]
              > hasn't[color=green][color=darkred]
              > > > > shipped, so it doesn't return a shipped date.
              > > > >
              > > > > How can I get this code resolved to where it doesn't blow up on[/color][/color][/color]
              this?[color=blue][color=green][color=darkred]
              > > > >
              > > > > This code runs in traditional ASP, but does not run in ASP.NET,[/color][/color]
              > because[color=green]
              > > of[color=darkred]
              > > > > the error above.
              > > >
              > > > Could you show us where you're getting WhatCol from?
              > > >
              > > > A lot of things run in VBScript that don't run in VB.NET. That's[/color][/color][/color]
              because[color=blue][color=green][color=darkred]
              > > > VBScript allowed developers to get away with murder. If you really[/color][/color][/color]
              want[color=blue]
              > to[color=green][color=darkred]
              > > > improve your coding, turn Options Strict On. You'll find many places[/color][/color]
              > where[color=green][color=darkred]
              > > > VB.NET was trying to "guess the right thing".
              > > > --
              > > > John Saunders
              > > > johnwsaundersii i at hotmail
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Scott M.

                #8
                Re: Operator is not valid for type 'DBNull' and type 'Date'

                Well, my advice would be to re-write this code using .NET strategies and
                classes, rather that just making your classic ASP code "work" inside of
                ..NET.

                It's hard to tell exactly what the code you posted is doing because it is
                incomplete. Perhaps if you posted the whole sub-routine....


                <me@privacy.net > wrote in message
                news:umsWzCWTEH A.3140@tk2msftn gp13.phx.gbl...[color=blue]
                > <<You really should leave this as a classic ASP page until you are ready[/color]
                to[color=blue]
                > fully convert it to ASP .NET. You are still using all the classic ASP
                > methodologies in an ASP .NET architecture. You'll find that using a
                > DataGrid and binding it to the data returned from your query is much[/color]
                easier[color=blue]
                > than all the inline coding that you are doing.>>
                >
                > We had started doing exactly what you're describing. However, we
                > encountered a problem for which I have been unable to find a solution.[/color]
                That[color=blue]
                > problem was saving to Excel. Lots of the reports we create, our users[/color]
                will[color=blue]
                > save them to excel and work with them, in terms of developing forecasts,
                > etc. With the controls on screen, we found that we had a little better[/color]
                than[color=blue]
                > a 50% failure rate in either opening the file in excel, or if the report[/color]
                was[color=blue]
                > a large one, it'd prompt you a number of times for a user id & password[/color]
                and[color=blue]
                > wouldn't ever produce the excel sheet. The problem in the opening the[/color]
                file[color=blue]
                > in excel was due directly to the controls being on the screen. Since we
                > have a number of variables that go in to producing the reports, it was
                > impractical to try to convert a 2nd page that'd load the report in a[/color]
                format[color=blue]
                > that COULD be saved and opened in Excel.
                >
                > I posted the problem I had with both of them numerous times in one of the
                > framework.aspne t groups, and was never able to find a satisfactory
                > resolution. At that point, we decided to just take our traditional asp
                > application, and convert it to dotnet, when we found that a number of the
                > reports we generated all would save & open in Excel, when we created them
                > with the converted report writer.
                >
                > <<And, from my earlier post, if you check a field for DBNull (either by
                > comparing against DBNull.Value or using IsDBNull(field) ) before you[/color]
                attempt[color=blue]
                > to use it, you're problem will be solved.>>
                >
                > I've tried this, but evidently, I did not have the check in the right[/color]
                place.[color=blue]
                >
                > I had:
                >
                > If Not IsDBNull(WhatCo l.Value) then
                > If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt)) AND
                > (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
                > If rownumber = 3 Then
                > thisfield = WhatCol.Value
                > GroupField(lcnt ) = GroupField(lcnt ) + 1
                > Else
                > 'Added the linecount < NrGroups times 2 which not
                > suppress duplicates on any field except Group Fields
                > 'If you need to change it back insert (thisfield =
                > showblank) in place of If Statement.
                > If lcnt < (NrGroups * 2) + 1 Then
                > thisfield = showblank
                > GroupField(lcnt ) = GroupField(lcnt ) + 1
                > Else
                > thisfield = WhatCol.Value
                > End IF
                > End IF
                > Else
                > thisfield = sData(rownumber , lcnt)
                > GroupField(lcnt ) = 0
                > End IF
                > Else
                > thisfield = sData(rownumber ,lcnt)
                > GroupField(lcnt ) = 0
                > End if
                >
                > It still gave me the dbnull error.
                >
                > SC
                >
                >
                >
                >[color=green]
                > >
                > >
                > > <me@privacy.net > wrote in message
                > > news:uWaWXcNTEH A.368@TK2MSFTNG P10.phx.gbl...[color=darkred]
                > > > The source data is from a SQL query that I'm running to display a web[/color]
                > > page.[color=darkred]
                > > > Some sample results are:
                > > >
                > > >
                > > > BUSINESS AREA1 REPORTGROUP1 06-02-2004[/color][/color]
                > 50257.0000[color=green][color=darkred]
                > > > BUSINESS AREA1 REPORTGROUP2 06-03-2004[/color][/color][/color]
                30604.0000[color=blue][color=green][color=darkred]
                > > > BUSINESS AREA1 REPORTGROUP3 05-28-2004[/color][/color]
                > 2475.0000[color=green][color=darkred]
                > > > BUSINESS AREA1 REPORTGROUP4 06-03-2004 7763.0000
                > > > BUSINESS AREA1 REPORTGROUP5 NULL 3.0000
                > > > BUSINESS AREA2 REPORTGROUP1[/color][/color][/color]
                06-04-2004[color=blue][color=green][color=darkred]
                > > > 219628.0000
                > > > BUSINESS AREA2 REPORTGROUP2 06-04-2004
                > > > 126966.0000
                > > > BUSINESS AREA2 REPORTGROUP3 06-03-2004[/color][/color]
                > 2599.0000[color=green][color=darkred]
                > > > BUSINESS AREA2 REPORTGROUP4 06-04-2004
                > > > 692.0000
                > > > BUSINESS AREA2 REPORTGROUP5 06-04-2004
                > > > 21805.0000
                > > >
                > > >
                > > > What it's doing is printing out the first column, then second column,[/color][/color]
                > and[color=green][color=darkred]
                > > > then it dies, when it hits the date column that's null.
                > > >
                > > > Like you said, VBScript would let you get away with some stuff, but I[/color][/color]
                > have[color=green][color=darkred]
                > > > no idea why this null in a return dataset would cause this thing to[/color][/color][/color]
                give[color=blue][color=green]
                > > me[color=darkred]
                > > > an error in dotnet. Traditional ASP didn't have a problem with it.[/color][/color][/color]
                I'm[color=blue][color=green]
                > > not[color=darkred]
                > > > totaling on the field or anything, either.
                > > >
                > > >
                > > >
                > > >
                > > > The code to do the whole routine is here:
                > > >
                > > >
                > > >
                > > > <tr>
                > > > <td><table border="9" align="center"
                > > > style="font-family: Arial; font-size: 9pt; border: medium none"
                > > > bordercolor="#0 00000">
                > > > <%
                > > > End IF
                > > > %>
                > > >
                > > > <tr>
                > > > <%
                > > > 'Put Headings On The Table of Field Names
                > > > 'redim sData(rs.record count,175)
                > > > rownumber = 3
                > > > colnumber = 0
                > > > BeenThere = 0
                > > > lcnt = 0
                > > > numcols = 0
                > > > actualcols = 0
                > > > NrGroups = 0
                > > > For Each WhatCol In rstemp.Fields
                > > > If Len(WhatCol.Nam e) <> 1 Then
                > > > thisfield = WhatCol.Name
                > > > GroupField(lcnt ) = 0
                > > > numcols = numcols + 1
                > > > %>
                > > >
                > > > <td bgcolor="#FFFFF F" align="center"> <p align="center"> <font
                > > > color="#000000" ><b><%= thisfield %></b></font></td>
                > > > <%
                > > > Else
                > > > 'All 1 Character Field Names are Grouping Fields
                > > > 'This sets up the grouping with hierachy determined from[/color][/color]
                > left[color=green]
                > > to[color=darkred]
                > > > right in SQL
                > > > GroupField(lcnt ) = 1
                > > > NrGroups = NrGroups + 1
                > > > End IF
                > > > actualcols = actualcols + 1
                > > > lcnt = lcnt + 1
                > > > Next
                > > > TBorder = "border:med ium none "
                > > > %>
                > > >
                > > > </tr>
                > > > <%
                > > > 'Now lets grab all the records
                > > > rownumber = 3
                > > > bgcolor = "white"
                > > > Do Until rstemp.EOF
                > > > %>
                > > >
                > > > <tr>
                > > > <%
                > > > lcnt = 0
                > > > 'Prepare Row for Printing
                > > > For Each WhatCol In rstemp.Fields
                > > > 'Load data to array
                > > > sData(rownumber , lcnt) = WhatCol.Value
                > > > 'If Data Type is currency, real or float
                > > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
                > > > GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
                > > > WhatCol.Value
                > > > End IF
                > > > 'Suppress Duplicates for Printing
                > > > 'Set up the first row for Grouping
                > > > If rownumber = 3 Then
                > > > sData(rownumber - 1, lcnt) = WhatCol.Value
                > > > End IF
                > > > If (sData(rownumbe r, lcnt) = sData(rownumber - 1, lcnt))[/color][/color][/color]
                AND[color=blue][color=green][color=darkred]
                > > > (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
                > > > If rownumber = 3 Then
                > > > thisfield = WhatCol.Value
                > > > GroupField(lcnt ) = GroupField(lcnt ) + 1
                > > > Else
                > > > 'Added the linecount < NrGroups times 2 which not
                > > > suppress duplicates on any field except Group Fields
                > > > 'If you need to change it back insert (thisfield =
                > > > showblank) in place of If Statement.
                > > > If lcnt < (NrGroups * 2) + 1 Then
                > > > thisfield = showblank
                > > > GroupField(lcnt ) = GroupField(lcnt ) + 1
                > > > Else
                > > > thisfield = WhatCol.Value
                > > > End IF
                > > > End IF
                > > > Else
                > > > thisfield = sData(rownumber , lcnt)
                > > > GroupField(lcnt ) = 0
                > > > End IF
                > > > 'Total Rows Field Length is 1 Character
                > > > If Len(WhatCol.Nam e) <> 1 Then
                > > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
                > > > thisfield = FormatNumber(CD bl(thisfield), 0)
                > > > End IF
                > > > %>
                > > >
                > > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
                > > > style="border: medium none"><%= thisfield %>
                > > > <%
                > > > End IF
                > > > lcnt = lcnt + 1
                > > > Next
                > > > rstemp.MoveNext ()
                > > > 'set or reset data
                > > > ralign = "right"
                > > > 'Change colors for every other line
                > > > If chgcolor = 0 Then
                > > > bgcolor = "#FFFFCC"
                > > > chgcolor = 1
                > > > Else
                > > > bgcolor = "White"
                > > > chgcolor = 0
                > > > End IF
                > > > 'End Totals and Grouping
                > > > lcnt = 0
                > > > If Not rstemp.EOF Then
                > > > For Each WhatCol In rstemp.Fields
                > > > If Len(WhatCol.Nam e) = 1 Then
                > > > If WhatCol.Value.T oString() <>[/color][/color][/color]
                CStr(sData(rown umber,[color=blue][color=green][color=darkred]
                > > > lcnt)) Then
                > > > PrintTotal(lcnt ) = lcnt
                > > > GroupField(lcnt ) = 1
                > > > Else
                > > > 'if rownumber<>3 then
                > > > rowCnt(lcnt) = rowCnt(lcnt) + 1
                > > > 'end if
                > > > GroupField(lcnt ) = 0
                > > > End IF
                > > > lcnt = lcnt + 1
                > > > End IF
                > > > Next
                > > > End IF
                > > > If rstemp.EOF Then
                > > > lcnt = 0
                > > > For Each WhatCol In rstemp.Fields
                > > > If Len(WhatCol.Nam e) = 1 Then
                > > > If sData(rownumber - 1, lcnt) = sData(rownumber ,[/color][/color]
                > lcnt)[color=green][color=darkred]
                > > > AND CStr(sData(rown umber, lcnt)) <> "" Then
                > > > PrintTotal(lcnt ) = lcnt
                > > > GroupField(lcnt ) = 1
                > > > 'rowcnt(lcnt) = rowcnt(lcnt)+1
                > > > Else
                > > > PrintTotal(lcnt ) = NrGroups + 1
                > > > 'if rownumber<>3 then
                > > > rowCnt(lcnt) = 0
                > > > 'end if
                > > > GroupField(lcnt ) = 0
                > > > End IF
                > > > 'lcnt = lcnt + 1
                > > > End IF
                > > > lcnt = lcnt + 1
                > > > Next
                > > > End IF
                > > > lcnt = 0
                > > > iGroup = 0
                > > > For tcnt = 0 To NrGroups
                > > > pcnt = NrGroups - tcnt
                > > > If CInt(PrintTotal (pcnt)) < NrGroups AND[/color]
                > > (CInt(GroupFiel d(pcnt))[color=darkred]
                > > > = 1 AND CInt(rowCnt(pcn t)) > 0) Then
                > > > GroupField(pcnt ) = 0
                > > > 'rowcnt(pcnt) = 0
                > > > If CInt(rowCnt(pcn t)) > 0 Then
                > > > Response.Write( "</tr><tr>")
                > > > End IF
                > > > For Each WhatCol In rstemp.Fields
                > > > If Len(WhatCol.Nam e) <> 1 Then
                > > > If CInt(rowCnt(pcn t)) < 1 AND (WhatCol.Type =[/color][/color][/color]
                5[color=blue][color=green]
                > > AND[color=darkred]
                > > > WhatCol.Type = 6) Then
                > > > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
                > > > End IF
                > > > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type <>[/color][/color][/color]
                5[color=blue][color=green]
                > > AND[color=darkred]
                > > > WhatCol.Type <> 6) Then
                > > > If lcnt = CInt((NrGroups) +[/color][/color]
                > PrintTotal(pcnt ))[color=green][color=darkred]
                > > > Then
                > > > sTotals = CStr(sData(rown umber, lcnt))
                > > > '& "-" & rowcnt(pcnt) & WHATCOL.TYPE
                > > > Else
                > > > sTotals = showblank
                > > > End IF
                > > > If CInt(rowCnt(pcn t)) > 0 Then
                > > > Response.Write( "<TD style=" & TBorder[/color][/color][/color]
                &[color=blue]
                > "[color=green][color=darkred]
                > > > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
                > > > "</FONT></STRONG></TD>")
                > > > End IF
                > > > End IF
                > > > If Len(WhatCol.Nam e) <> 1 AND (WhatCol.Type =[/color][/color][/color]
                5[color=blue]
                > Or[color=green][color=darkred]
                > > > WhatCol.Type = 6) Then
                > > > For colcount = 0 To rowCnt(pcnt)
                > > > atotals = sData(rownumber - colcount,[/color]
                > > lcnt)[color=darkred]
                > > > + atotals
                > > > Next
                > > > atotals = FormatNumber(CD bl(atotals), 0)
                > > > If CInt(rowCnt(pcn t)) > 0 Then
                > > > Response.Write( "<TD style=" & TBorder[/color][/color][/color]
                &[color=blue]
                > "[color=green][color=darkred]
                > > > ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
                > > > "</FONT></STRONG></TD>")
                > > > End IF
                > > > GrpTotal(lcnt, PrintTotal(pcnt )) = 0
                > > > atotals = 0
                > > > End IF
                > > > End IF
                > > > lcnt = lcnt + 1
                > > > Next
                > > > If CInt(rowCnt(pcn t)) > 0 Then
                > > > Response.Write( "</tr><tr>")
                > > > BeenThere = BeenThere + 1
                > > > End IF
                > > > rowCnt(pcnt) = 0
                > > > 'Change colors for every other line
                > > > If chgcolor = 0 Then
                > > > bgcolor = "#FFFFCC"
                > > > chgcolor = 1
                > > > Else
                > > > bgcolor = "White"
                > > > chgcolor = 0
                > > > End IF
                > > > End IF
                > > > lcnt = 0
                > > > Next
                > > > rownumber = rownumber + 1
                > > > Loop
                > > > %>
                > > >
                > > > </td>
                > > > </tr>
                > > > <tr>
                > > > <%
                > > > 'Grand Total Routine
                > > > lcnt = 0
                > > > col1 = 0
                > > > If NrGroups > 0 Then
                > > > 'If any 1 character fields where defined, Grand Totals will[/color][/color]
                > appear[color=green][color=darkred]
                > > > For Each WhatCol In rstemp.Fields
                > > > If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
                > > > sTotal = FormatNumber(CD bl(GrandTotal(l cnt + 1, 0)),[/color][/color][/color]
                0)[color=blue][color=green][color=darkred]
                > > > %>
                > > >
                > > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
                > > > style="border-left: medium none; border-right: medium none;
                > > > border-top: medium double; border-bottom: medium none"><strong>< %=[/color]
                > > (sTotal)[color=darkred]
                > > > %></strong>
                > > > <%
                > > > sTotal = 0
                > > > Else
                > > > If Len(WhatCol.Nam e) <> 1 Then
                > > > If col1 = 0 Then
                > > > sTotal1 = "Grand Total"
                > > > col1 = 1
                > > > Else
                > > > sTotal1 = showblank
                > > > End IF
                > > > Else
                > > > sTotal1 = showblank
                > > > End IF
                > > > If Len(WhatCol.Nam e) <> 1 Then
                > > > %>
                > > > </td>
                > > > <td bgcolor="<%= bgcolor %>" valign="top" align="right"
                > > > style="border-left: medium none; border-right: medium none;
                > > > border-top: medium double; border-bottom: medium none"><strong>< %=[/color][/color]
                > sTotal1[color=green][color=darkred]
                > > > %></strong>
                > > > <%
                > > > End IF
                > > > End IF
                > > > lcnt = lcnt + 1
                > > > Next
                > > > %>
                > > > </td>
                > > > </tr>
                > > > <%
                > > > End IF
                > > > Session.Add("rp tend", Timer())
                > > > Session.Add("rp ttime", FormatNumber(CD bl(Session("rpt end")) -
                > > > CDbl(Session("r ptstart")), 1))
                > > > rstemp.Close()
                > > > rstemp = Nothing
                > > > conntemp.Close( )
                > > > conntemp = Nothing
                > > > %>
                > > >
                > > > </table>
                > > > <p><small><%
                > > > Response.Write( "The report ran in " & Session("rpttim e") & "[/color]
                > > second(s)")[color=darkred]
                > > > %>
                > > > </small></td>
                > > > </tr>
                > > > </table>
                > > >
                > > >
                > > >
                > > >
                > > >
                > > >
                > > > "John Saunders" <johnwsaundersi ii@notcoldmail. com> wrote in message
                > > > news:ubatuDNTEH A.1168@TK2MSFTN GP11.phx.gbl...
                > > > > <me@privacy.net > wrote in message
                > > > > news:Owkao5MTEH A.2408@tk2msftn gp13.phx.gbl...
                > > > > > Source Error:
                > > > > >
                > > > > > Line 173: sData(rownumber - 1, lcnt) =[/color][/color][/color]
                WhatCol.Value[color=blue][color=green][color=darkred]
                > > > > > Line 174: End IF
                > > > > > Line 175: If (sData(rownumbe r, lcnt) =[/color][/color][/color]
                sData(rownumber -[color=blue]
                > 1,[color=green][color=darkred]
                > > > > > lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
                > > > > > Line 176: If rownumber = 3 Then
                > > > > > Line 177: thisfield = WhatCol.Value
                > > > > >
                > > > > >
                > > > > > In that, the Whatcol.Value is a null value, and I am trying to[/color][/color]
                > return[color=green]
                > > a[color=darkred]
                > > > > date
                > > > > > field, which is calculated MAX(j5_org.invo ice_date). The item[/color]
                > > hasn't[color=darkred]
                > > > > > shipped, so it doesn't return a shipped date.
                > > > > >
                > > > > > How can I get this code resolved to where it doesn't blow up on[/color][/color]
                > this?[color=green][color=darkred]
                > > > > >
                > > > > > This code runs in traditional ASP, but does not run in ASP.NET,[/color]
                > > because[color=darkred]
                > > > of
                > > > > > the error above.
                > > > >
                > > > > Could you show us where you're getting WhatCol from?
                > > > >
                > > > > A lot of things run in VBScript that don't run in VB.NET. That's[/color][/color]
                > because[color=green][color=darkred]
                > > > > VBScript allowed developers to get away with murder. If you really[/color][/color]
                > want[color=green]
                > > to[color=darkred]
                > > > > improve your coding, turn Options Strict On. You'll find many places[/color]
                > > where[color=darkred]
                > > > > VB.NET was trying to "guess the right thing".
                > > > > --
                > > > > John Saunders
                > > > > johnwsaundersii i at hotmail
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                Working...