Server Error in '/' Application.

Conversion from type 'DBNull' to type 'String' is not valid.

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: Conversion from type 'DBNull' to type 'String' is not valid.

Source Error:


Line 83:             ret &= GetFileContents(Me.MapPath("~/html/voceElenco.htm"))
Line 84:             ret = ret.Replace("<!--nome-->", impostaTesto(dr("nome"), 130))
Line 85:             ret = ret.Replace("<!--pagina-->", dr("n_pagina"))
Line 86:             If dr("foto").ToString = "" Then
Line 87:                 ret = ret.Replace("<!--foto-->", "assets/img/default.jpg")

Source File: D:\home\attrezzaturealimentazione.it\httpdocs\banco_pasticceria.aspx.vb    Line: 85

Stack Trace:


[InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.]
   Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value) +1307492
   banco_pasticceria.elencoProdotti(String q) in D:\home\attrezzaturealimentazione.it\httpdocs\banco_pasticceria.aspx.vb:85
   banco_pasticceria.Page_Load(Object sender, EventArgs e) in D:\home\attrezzaturealimentazione.it\httpdocs\banco_pasticceria.aspx.vb:25
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0