Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table called Mst_Stock the Columns are Stk_Qty dataType is Float and Stk_ItmNo DataType is Numeric.

When i wrote a below code to Deduct the Qty from Mst_Stock When i pass the Integer value then its ok, but when its decimal value then its goes to exponation.

Please help on this.

Below is the ASP.Net Code

VB
Private Sub Frm_StockUpdate(ByVal LdbM_NewStkQty As Double, ByVal LdbM_ItemNo As Double)

        Dim LdbM_TotalQty As Double

        con.Open()
        cmd = New SqlClient.SqlCommand("Select * from Mst_Stock Where Stk_ItmNo=" & LdbM_ItemNo & "", con)

        dr = cmd.ExecuteReader()
        If dr.HasRows Then
            While dr.Read
                If IsDBNull(dr("Stk_Qty")) = False Then
                    LdbM_TotalQty = dr("Stk_Qty")
                    LdbM_TotalQty = LdbM_TotalQty - LdbM_NewStkQty

                Else
                    'LdbM_TotalQty = LdbM_TotalQty + LdbM_NewStkQty
                End If


            End While
        End If
        con.Close()



        Dim LsM_Qryinsert2 As String
        con.Open()
        LsM_Qryinsert2 = "update Mst_Stock set Stk_Qty=@Stk_Qty Where Stk_ItmNo=" & LdbM_ItemNo & ""
        cmd = New SqlClient.SqlCommand(LsM_Qryinsert2, con)
        cmd.CommandType = CommandType.Text

        cmd.Parameters.AddWithValue("Stk_Qty", LdbM_TotalQty)

        cmd.ExecuteNonQuery()
        con.Close()

    End Sub


What problem if i use float.

Thanks Basit.
Posted
Comments
Herman<T>.Instance 8-Jul-15 11:27am    
what have you tried?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900