kekewong
Member
- Joined
- Mar 9, 2009
- Messages
- 7
- Programming Experience
- Beginner
Ok, my current situation is i got a datagridview , some field i bind it with my Food_Ordering dataset , some do not , and in my datagridview, i add 1 more button column and gives a delete function to do . That means , my mission is , user click the button of particular row, it should delete from the dataset Food_Ordering table and update into database .But it seems like the database wont update , but my datagridview item has been delete.
Ok, another finding that i found is . Assume that i have only 1 row of record in Food_Ordering. I press delete , the particular datagridview row has been delete, but i close the form and show it back , the record still remains . So , i try to press delete again , this time it says " there are no item in row (0). So, i was wondering, the dataset table has been successfully delete the row, but it just haven update into the database . I tried to open the database and see whether the record is still there, and the answer is yes . The record never delete in database. So ... Why is this happening? Below is some of my codes .
Ok, another finding that i found is . Assume that i have only 1 row of record in Food_Ordering. I press delete , the particular datagridview row has been delete, but i close the form and show it back , the record still remains . So , i try to press delete again , this time it says " there are no item in row (0). So, i was wondering, the dataset table has been successfully delete the row, but it just haven update into the database . I tried to open the database and see whether the record is still there, and the answer is yes . The record never delete in database. So ... Why is this happening? Below is some of my codes .
VB.NET:
Private Sub dgvFoodOrdering_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvFoodOrdering.CellContentClick
If (e.ColumnIndex = dgvFoodOrdering.Columns("Delete").Index) Then
If (MessageBox.Show("Do you really want to delete this record?", "Delete Comfirmation", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes) Then
ds.Tables("Food_Ordering").Rows.Remove(ds.Tables("Food_Ordering").Rows(e.RowIndex))
dgvFoodOrdering.Rows.RemoveAt(e.RowIndex)
daFoodOrder.Update(ds)
End If
End If
End Sub