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