Results 1 to 2 of 2

Thread: [2005] Saving the changes made to a datagridview.

  1. #1

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

    [2005] Saving the changes made to a datagridview.

    Hello,

    I have a datagridview which I fill with data using a bindingsource. I am using typed datasets and have set the properties of the bindingsource to the typed dataset and data table using the designer. I can then use the table adapter to fill the dataset and assign the data source of the datagridview to the bindingsource. This works fine. My code shows below.

    However, I am not sure about the code that will allow me to edit the datagridview and then save all the changes. The user will enter or edit some of the values in the grid. Once they have finished they will click a button to save all changes to the database.

    Does anyone have any code samples of this?

    Many thanks for any advice,

    Code:
    'Fill the software part
        Private Sub FillSoftware()
            Try
                Me.TA_Software_dsComponent_Equipment.Fill(Me.DsAddComponetAndEquipment.Software)
                Me.dgvSoftware.DataSource = Me.bsSoftware
    
                Me.HideSoftwareColumns()
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    steve

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2005] Saving the changes made to a datagridview.

    Something like this straight from MSDN:

    vb.net Code:
    1. Try
    2.     Me.Validate()
    3.     Me.CustomersBindingSource.EndEdit()
    4.     Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
    5.     MsgBox("Update successful")
    6.  
    7. Catch ex As Exception
    8.     MsgBox("Update failed")
    9. End Try

    More detail here. Good luck!

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