Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Specified cast is not valid
Message
 
 
À
22/04/2016 15:03:02
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01635259
Message ID:
01635260
Vues:
42
Did you try using (decimal?) instead of (decimal)

?

>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform