Hi. My problem is, the data that I pull from the database, when try to multiply it, it didn't multiply.
The database has Fruit and FruitPrice column. When select fruit form the combo box, it will search the price. But I can't seem to multiply it. The price is display at PriceTextBox but when multiply it, it shows 0 in the TotalTextBox. It is a simple problem but I've tried everything I know but it still didn't multiply.
This is my search coding:
con.ConnectionString = "PROVIDER=Microsoft.Jet.Oledb.4.0; Data source =C:\Documents and Settings\~LaiLi~\My Documents\Visual Studio 2005\Projects\MoreWever\MoreWever\bin\Debug\Inventory.mdb"
sql = "SELECT * FROM Sales WHERE Fruit = '" & FruitComboBox.Text & "'"
con.Open()
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim FruitDecimal, TotalPrice, FruitPrice As Decimal
Dim QuanNum As Integer
cmd = New OleDbCommand(sql, con)
dr = cmd.ExecuteReader
While dr.Read()
FruitDecimal = dr("FruitPrice")
FruitPrice = FruitDecimal
End While
TotalPrice = FruitPrice * QuanNum
QuanNum = Integer.Parse(QuantityTextBox.Text)
PriceTextBox.Text = FruitPrice.ToString()
TotalTextBox.Text = TotalPrice.ToString()
con.Close()
Hope someone has any idea about it.