Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > code prob, upgrading from traditional asp to asp.net

Reply
Thread Tools

code prob, upgrading from traditional asp to asp.net

 
 
Guest
Posts: n/a
 
      06-07-2004
I have an application that I'm converting from traditional ASP to asp.net,
using visual basic to code with.

the line it doesn't like is: "If (sData(rownumber, lcnt) =
sData(rownumber - 1, lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6)
Then "

The error message is:


Server Error in '/test' Application.
----------------------------------------------------------------------------
----

Operator is not valid for type 'DBNull' and type 'Date'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: 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(rownumber, 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.

What it's the result of is a SQL query in which I am doing a union join of 2
select statements. The field that it doesn't like is a date field, which is
set by using MAX(j5_org.inv_date). If the item hasn't had any shipments of
it, then I believe Null is a correct value for that field. At least, the
NULL shows up in the query as it's run in Query analyzer.

I'd rather fix my code than to go thru all of the stored procedures that'd
have a potential null value in them.

This application runs in traditional ASP, and the nulls do not seem to cause
a problem there, but they do in dotnet.


The Dotnet code it yaks on is:

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(rownumber, 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.Name) <> 1 Then
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
thisfield = FormatNumber(CDbl(thisfield), 0)
End IF


The original source code is:

<% lcnt = 0
' Prepare Row for Printing
for each WhatCol in rstemp.fields
'Load data to array
sData(rownumber,lcnt) = whatcol.value
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(rownumber,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.name) <> 1 then
if whatcol.type = 6 or whatcol.type = 5 then
thisfield = formatnumber(thisfield,0)
End If
%>

Any advice appreciated.

Thanks,

SC



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Traditional desktop wizard behaviour... in ASP.Net application Cris Rock ASP .Net 2 02-11-2004 10:59 PM
ASP.net and traditional ASP Robert Storrs ASP .Net 5 12-12-2003 03:49 PM
Debugging traditional asp pages under VS.NET 2003 Jan ASP .Net 2 11-03-2003 08:43 AM
Can a traditional ASP site be done with VS? Bruce W...1 ASP .Net 3 10-31-2003 08:47 PM



Advertisments