VB.NET:
Private Sub RCUTsaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RCUTsaveBtn.Click
conn.Open()
Try
'Command run if save sucessfully
Dim myCommand As OracleClient.OracleCommand
Dim ra As Integer
For i As Integer = 0 To Me.DataGrid.Rows.Count - 2
myCommand = New OracleClient.OracleCommand("UPDATE TABLE1 SET CAUSE = '" & Me.DataGrid.Rows(i).Cells("CAUSE").Value & "' WHERE NO = '" & Me.DataGrid.Rows(i).Cells("NO").Value & "'", conn)
ra = myCommand.ExecuteNonQuery()
Next
MessageBox.Show("Save Successful! Records Affect: " & ra, "ASO TAG DTL", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
'Error message catch when update cannot be save
MessageBox.Show("Unable to Save! " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
conn.Close()
End Sub
I got this code above to work fine, but one problem I am having is this code (i think, but I am not sure)
VB.NET:
MessageBox.Show("Save Successful! Records Affect: " & ra, "ASO TAG DTL", MessageBoxButtons.OK, MessageBoxIcon.Information)
No matter how many records it update, it only said Save Sucessful! Records Affect: 1. But I know there are at least more than one is update. Please guide me to right direction. Thank you very much.