Delete Record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new to coding and vb. I need some help on how to delete a record from a
datagrid that I have in a form. I am unable to locate any info on the web
(it seems as though it is all asp) or from the help file. Below I have given
two examples of code that I am working with, one is to load my datagrid and
the other is to update my datagrid. Can someone please help with deleting a
record from my datagrid?

Private Sub Book_Load
School11.Clear()
OleDbDataAdapter1.Fill(School11)
End Sub

Private Sub btnUpdate
Dim mynumber As Double
Me.BindingContext(School11, "Student").AddNew()
OleDbDataAdapter1.Update(School11)
MessageBox.Show("Database has been updated")
btnReload_Click(sender, e)
Me.BindingContext(School11, "Student").Position =
BindingContext(School11, "student").Count + 1
mynumber = Val(txtPhoneNumber.Text)
txtPhoneNumber.Text = Format(mynumber, "(###)-###-####")
End Sub
 
You don't remove a row from the grid, you remove it from
your datasource

Kind of hard to tell what you're working with
It looks like School11 is your datasource
If so is it a DataTable or a DataSet or something else?

Basically you call one of the following to remove a row
from a datatable:
yourTable.Rosw.Remove(...)
yourTable.Rows.RemoveAt(...)


/claes
 
Hello,

You will want to remove the record from the data source (ie DataSet,
DataTable, ArrayList, etc) then it will be removed from the DataGrid.

Tom

This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top