Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Specified cast is not valid
Message
From
22/04/2016 15:03:02
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Specified cast is not valid
Environment versions
Environment:
C# 4.0
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01635259
Message ID:
01635259
Views:
71
Hi,

I've inherited an ASP.NET application which makes use of DataSets and TableAdapters for displaying/editing data.

I've added in 2 new columns to a table, with all the vales in these columns being null. I've adjusted the DataTable and TableAdpaters accordingly.

Now when I try to access a web page which uses this table, but does not display either of these new fields, I get this error:
Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error: 


Line 11323:                get {
Line 11324:                    try {
Line 11325:                        return ((decimal)(this[this.tablePNRs.ChargeColumn]));
Line 11326:                    }
Line 11327:                    catch (global::System.InvalidCastException e) {

Source File: D:\Development\VS2010\RESREPRICER_asp4\RESREPRICERDataSet.Designer.cs    Line: 11325 

Stack Trace: 


[InvalidCastException: Specified cast is not valid.]
   RESREPRICER.Web.PNRsRow.get_Charge() in D:\Development\VS2010\RESREPRICER_asp4\RESREPRICERDataSet.Designer.cs:11325

[StrongTypingException: The value for column 'Charge' in table 'PNRs' is DBNull.]
   RESREPRICER.Web.PNRsRow.get_Charge() in D:\Development\VS2010\RESREPRICER_asp4\RESREPRICERDataSet.Designer.cs:11328
   RESREPRICER.Web.PrepareInvoicesEdit.butCreate_Click(Object sender, EventArgs e) in D:\Development\VS2010\RESREPRICER_asp4\PrepareInvoicesEdit.aspx.cs:217
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628614
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
What do I need to do to fix this?

This will also lead me on to other issues with passing in nulls to the insert an dupdate of this data, but I'll leave that alone until I understand what's going on here.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform