Skip to content

SOLVED : Binding decimal data Update command Gridview problem

Mata

Asked Dec 13, 2011, 4:07 AM EST1 answer
Share
LinkedInX
Don't know in what section this question goes but here I go.

I'm getting Truncated incorrect DOUBLE value:'20,12' error (this is value I had  in edittamplate textbox of gridview, not the new updated value in textbox in edittamplate ).
I'm using mySQL database. I get this error everytime I put some value ( I think decimal data is problem generally to this to work) in textbox and than push Update button of a gridview to trigger Update command. I think whole process about Updating decimal values and binding decimal data to textbox is the problem. It is funny that insert of new records (with decimal values) work ok. So maybe who knows mysql and asp.net can help me with this. Maybe there are some restrictions. thx

Binding is done like this:

<asp:TemplateField HeaderText="Cijena" SortExpression="cijena">
                                <ItemTemplate>
                                    <asp:Label ID="lbcijenaDostave" runat="server" Text='<%# Bind("cijena") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="tbcijenaDostave" runat="server" Text='<%# Bind("cijena") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="tbcijenaDostaveFoot" runat="server" Visible="false"></asp:TextBox>
                                </FooterTemplate>
                            </asp:TemplateField>



SQL DATA SOURCE PART
<asp:SqlDataSource ID="SQLLocal2" runat="server" ConnectionString="<%$ ConnectionStrings:dbSQL %>" OldValuesParameterFormatString="old_{0}" ConflictDetection="CompareAllValues"
                        ProviderName="<%$ ConnectionStrings:dbSQL.ProviderName %>" 
                        SelectCommand="SELECT id_dostave, naziv, cijena FROM nacin_dostave"
                        UpdateCommand="UPDATE nacin_dostave SET naziv=@naziv, cijena=@cijena WHERE id_dostave=@old_id_dostave AND naziv=@old_naziv AND cijena=@old_cijena"
                        DeleteCommand="DELETE FROM nacin_dostave WHERE id_dostave=@old_id_dostave"
                        InsertCommand="INSERT INTO nacin_dostave (naziv,cijena) VALUES (@naziv,@cijena)">
                        <UpdateParameters>
                        <asp:Parameter Name="naziv" />
                        <asp:Parameter Name="cijena" DbType="Decimal" />
                        </UpdateParameters>
                        <InsertParameters>
                        <asp:Parameter Name="naziv" />
                        <asp:Parameter Name="cijena" DbType="Decimal" />
                        </InsertParameters>
                    </asp:SqlDataSource>


1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    It seems that something is wrong in this part of Update command "AND cijena=@old_cijena" .Cijena is decimal ,and it seems there is somekind of problem with handling and comparing old decimal values. But maybe this is only issue with mysql database.
    bottom line is when I removed above string, issue was gone
    0