Basit Khan

Basit Khan

  • NA
  • 336
  • 121.6k

SQL DataType Float giving/return exponationa value

Jun 23 2015 2:25 AM
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
 
 
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.