You have to remove the item from the database that the datagrid is getting the information from, instead of just the actual datagrid. Heres a example.
If Grid2.SelectedCells.Count <> 0 Then
Table2TableAdapter.Connection.Open()
Dim I As Integer = Grid2.CurrentCell.RowIndex
TestdbDataSet.Table2.Rows.Item(I).Delete()
TestdbDataSet.GetChanges()
Table2TableAdapter.Update(TestdbDataSet.Table2)
Table2TableAdapter.Connection.Close()
Else
MsgBox("There are no items selected.")
End If
cellus205
Junior Poster in Training
57 posts since May 2007
Reputation Points: 10
Solved Threads: 3
Well. Im still kinda new to VB .NET, but Datagrids are basically only representative of a dataset, they dont actually store the data. So in effect, the datagrid only shows what the actual dataset contains. One way you can get around deleting the data from the actual dataset is to create a copy of the dataset, and actually delete data from that set. Heres an example:
Dim tempTable As New testdbDataSet.Table1
Table1TableAdapter.Fill(tempTable)
DataGrid.DataSource = tempTable
And then you can delete data from the tempTable datatable instead of your actual database.
cellus205
Junior Poster in Training
57 posts since May 2007
Reputation Points: 10
Solved Threads: 3
Welcome vijay2040.
I'm glad you got it helpful. Please do not resurrect old threads. If you have any questions please ask. .... You are welcome to start your own threads.
Thread Closed.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241