Good Evening All
I recently received some help on here from some of the guys in regards to updating a datagridview & saving the changes back to my database & they sorted the problem straight out.
However i have now come across another problem with the code which was working previously. I have added a section to the CellEndEdit code to automatically update & calculate one of the columns however now my update isnt working. Well it is however the last thing to change isnt being saved to the database.
Any ideas?
Many thanks in advanced
Frosty
I recently received some help on here from some of the guys in regards to updating a datagridview & saving the changes back to my database & they sorted the problem straight out.
However i have now come across another problem with the code which was working previously. I have added a section to the CellEndEdit code to automatically update & calculate one of the columns however now my update isnt working. Well it is however the last thing to change isnt being saved to the database.
Any ideas?
Code:
Private Sub dGridMaterials_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dGridMaterials.CellEndEdit
Dim intTotalMaterialCost As Decimal, intPurchaseCost As Decimal, intPurchaseSize As Decimal, strTotalCost As String = "0"
For Each dGridRow As DataGridViewRow In dGridMaterials.Rows
intPurchaseCost = dGridRow.Cells(7).Value
intPurchaseSize = dGridRow.Cells(6).Value
If intPurchaseCost <> 0 Or intPurchaseSize <> 0 Then
intTotalMaterialCost = intPurchaseSize / intPurchaseCost
dGridRow.Cells(8).Value = intTotalMaterialCost
End If
Next
dGridMaterials.EndEdit()
Dim sqlCommandBuilder As New SqlCommandBuilder(sqlDataAdapter)
sqlDataAdapter.Update(sqlDataTable)
End Sub
Frosty