PC Review


Reply
Thread Tools Rate Thread

asp to asp.net dbnull error

 
 
amitbadgi@gmail.com
Guest
Posts: n/a
 
      3rd Aug 2005
Hi I am converting an asp to asp.net, i m getting this error in one of
the files,

Operator '=' is not defined for type 'DBNull' and string "Y".
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
defined for type 'DBNull' and string "Y".

Source Error:

Line 259:<p>
<%=(rs_eventtype.Fields.Item("description").Value)%></p></td>
Line 260: <td align="center">
Line 261: <% if (rs_eventtype.Fields.Item("alwayson").Value) = "Y"
then %>
Line 262: <em>always on</em>
Line 263: <% else %>


Source File: C:\Documents and
Settings\amit\WebSite1\list_event_type.aspx Line: 261

Stack Trace:

[InvalidCastException: Operator '=' is not defined for type 'DBNull'
and string "Y".]

Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(Object
Left, Object Right, Boolean TextCompare) +135
ASP.list_event_type_aspx.__Render__control1(HtmlTextWriter __w,
Control parameterContainer) in C:\Documents and
Settings\amit\WebSite1\list_event_type.aspx:261
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878

 
Reply With Quote
 
 
 
 
msnews.microsoft.com
Guest
Posts: n/a
 
      3rd Aug 2005
In the query that you are using to retrieve the data from the database, use
an ISNULL (or some other equivalent) to return 'N' (or some other value,
depending on your logic) for NULL values.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi I am converting an asp to asp.net, i m getting this error in one of
> the files,
>
> Operator '=' is not defined for type 'DBNull' and string "Y".
> 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
> defined for type 'DBNull' and string "Y".
>
> Source Error:
>
> Line 259:<p>
> <%=(rs_eventtype.Fields.Item("description").Value)%></p></td>
> Line 260: <td align="center">
> Line 261: <% if (rs_eventtype.Fields.Item("alwayson").Value) = "Y"
> then %>
> Line 262: <em>always on</em>
> Line 263: <% else %>
>
>
> Source File: C:\Documents and
> Settings\amit\WebSite1\list_event_type.aspx Line: 261
>
> Stack Trace:
>
> [InvalidCastException: Operator '=' is not defined for type 'DBNull'
> and string "Y".]
>
> Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(Object
> Left, Object Right, Boolean TextCompare) +135
> ASP.list_event_type_aspx.__Render__control1(HtmlTextWriter __w,
> Control parameterContainer) in C:\Documents and
> Settings\amit\WebSite1\list_event_type.aspx:261
> System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
> ICollection children) +98
> System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
> System.Web.UI.Page.Render(HtmlTextWriter writer) +27
> System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
> ControlAdapter adapter) +53
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
> ControlAdapter adapter) +280
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> +8878
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Error on Dbnull and integers tshad Microsoft VB .NET 6 27th Nov 2005 10:06 PM
Error with DBNull Filipe Cristóvão Microsoft ASP .NET 2 1st Sep 2004 11:01 AM
DBNULL Error MadCrazyNewbie Microsoft VB .NET 2 5th May 2004 03:29 PM
Strange DBNULL Error - Please Help! Martin Microsoft ASP .NET 2 2nd Feb 2004 09:23 AM
Strange DBNULL Error - Please Help! Martin Feuersteiner Microsoft VB .NET 1 22nd Jan 2004 07:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 AM.