Note that there are some explanatory texts on larger screens.

plurals
  1. POException: 212,1 is not a valid value for Decimal
    primarykey
    data
    text
    <p>I create in MSSQL 2005 Express table Budgets with PK BudgetID (INT) and BudgetValue (MONEY) Then i create Entitty Model from DataBase</p> <p>And field BudgetValue was mapped as Decimal</p> <p>Then i create repository class like this</p> <pre><code>public class BudgetRepository : IDisposable { private moneytestEntities context = new moneytestEntities(); public IEnumerable&lt;Budgets&gt; GetBudgets() { return context.BudgetsSet.ToList(); } public void InsertBudgets(Budgets budgets) { try { context.BudgetsSet.AddObject(budgets); context.SaveChanges(); } catch (Exception err) { throw err; } } public void DeleteBudgets(Budgets budgets) { try { context.BudgetsSet.Attach(budgets); context.BudgetsSet.DeleteObject(budgets); context.SaveChanges(); } catch (Exception err) { throw err; } } private bool disposedValue = false; protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { context.Dispose(); } } this.disposedValue = true; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } } </code></pre> <p>and create WebForm1 like this</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetBudgets" TypeName="WebApplication13.DAL.BudgetRepository" DataObjectTypeName="WebApplication13.DAL.Budgets" InsertMethod="InsertBudgets" DeleteMethod="DeleteBudgets" oninserting="ObjectDataSource1_Inserting"&gt; &lt;/asp:ObjectDataSource&gt; &lt;asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource1" Height="50px" oniteminserted="DetailsView1_ItemInserted" Width="125px" DefaultMode="Insert"&gt; &lt;Fields&gt; &lt;asp:CommandField ShowInsertButton="True" /&gt; &lt;asp:DynamicField DataField="BudgetValue" HeaderText="BudgetValue" /&gt; &lt;/Fields&gt; &lt;/asp:DetailsView&gt; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" DataKeyNames="BudgetID"&gt; &lt;Columns&gt; &lt;asp:CommandField ShowDeleteButton="True" /&gt; &lt;asp:DynamicField DataField="BudgetValue" HeaderText="BudgetValue" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;br /&gt; &lt;asp:Label ID="ExceptionLabel" runat="server" Text="" ForeColor="Red"&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>and typed control</p> <pre><code>protected void Page_Init(object sender, EventArgs e) { DetailsView1.EnableDynamicData(typeof(Budgets)); GridView1.EnableDynamicData(typeof(Budgets)); } </code></pre> <p>When i insert value like 123 all ok But i when insert value like 123,45 i have exception</p> <p>Stack Trace: </p> <pre><code>[FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal) +9591983 System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +146 System.ComponentModel.DecimalConverter.FromString(String value, NumberFormatInfo formatInfo) +53 System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +302 [Exception: 212,1 is not a valid value for Decimal.] System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +489 System.Web.UI.WebControls.ObjectDataSourceView.ConvertType(Object value, Type type, String paramName) +117 System.Web.UI.WebControls.ObjectDataSourceView.BuildObjectValue(Object value, Type destinationType, String paramName) +167 System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject(Type dataObjectType, IDictionary inputParameters) +229 System.Web.UI.WebControls.ObjectDataSourceView.ExecuteInsert(IDictionary values) +290 System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +89 System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +379 System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +611 System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +112 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 </code></pre> <p>Any ideas?</p> <p>Thank!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload