Results 1 to 3 of 3

Thread: How to delete record from dataset?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    63

    How to delete record from dataset?

    I have customer/order form.When i delete a record from datagrid.It deletes the record but when i refresh the page or run the app again it comes because i think it just deletes temp from the grid not from the database.How do delete it from the database?

    Code:
     Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
            'Me.CustomerTableAdapter.Fill(Me.CustomerDataSet.Customer)
            'BindingSource1.Remove(CustomerDataSet.Customer)
            BindingSource1.RemoveCurrent()
         End Sub
    test1

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: How to delete record from dataset?

    What is your data source?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How to delete record from dataset?

    ADO.NET works in a disconnected state by default. So when you delete from the datatable, it is only removed from the datatable. To delete from the database, you will need to issue a proper DELETE SQL command one way or another. One would be to use the Table/DataAdaptor, setting the Delete command and using the .Update method to commit the changes to the database.

    The other way is to do it yourself, create a command object, setting the command text property and executing it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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