Results 1 to 2 of 2

Thread: [RESOLVED] Deleting row from a typed dataset

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved [RESOLVED] Deleting row from a typed dataset

    Hello,

    I am deleting a row from a row that is currently selected on a datagridview.

    I am using a Typed dataset and my datagridview is bounded to a binding source.

    However, I think my technique is not the best, even though it works.

    Many thanks for any advice,

    Code:
    Dim drDelete() As DataRow
    				' Get the value of the PK from the currently selected row
    				Dim drv As DataRowView = CType(bsAddressBook.Current, DataRowView)
    				Dim index As Integer = Convert.ToInt16(drv(0))
    
    				' Find the actual data row from the primary key and delete the row
    				drDelete = dsCATDialer.AddressBook.Select(String.Format("ID = '{0}'", index))
    				dsCATDialer.AddressBook.Rows.Remove(drDelete(0))
    steve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Deleting row from a typed dataset

    Just call RemoveCurrent on the BindingSource.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width