Server Error in '/' Application.

Object cannot be cast from DBNull to other types.

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: Object cannot be cast from DBNull to other types.

Source Error:


Line 28:         MySqlDataAdapter adp = new MySqlDataAdapter("select * from tbnws", ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
Line 29:         DataSet ds = new DataSet();
Line 30:         adp.Fill(ds);
Line 31:         Repeater1.DataSource = ds;
Line 32:         Repeater1.DataBind();

Source File: c:\inetpub\vhosts\bookraja.com\missioncat.in\Default.aspx.cs    Line: 30

Stack Trace:


[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider) +60
   MySql.Data.MySqlClient.Driver.LoadCharacterSets(MySqlConnection connection) +484
   MySql.Data.MySqlClient.Driver.Configure(MySqlConnection connection) +170
   MySql.Data.MySqlClient.MySqlConnection.Open() +523
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +182
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +180
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +126
   _Default.repbind() in c:\inetpub\vhosts\bookraja.com\missioncat.in\Default.aspx.cs:30
   _Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\bookraja.com\missioncat.in\Default.aspx.cs:23
   System.Web.UI.Control.OnLoad(EventArgs e) +108
   System.Web.UI.Control.LoadRecursive() +90
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533


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