Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update database using datagrid

Status
Not open for further replies.

pingu07

Programmer
Sep 29, 2011
1
PH
Can anyone give me an example how to use datagrid that will reflect its changes to your mysql database....

i havae tried doing th ff.

create the DataGridView (I let .NET create the BindingSource stuff)
Entered the following code into my 'Save' button click event:

Me.Validate()
Me.StgCustomerBindingSource.EndEdit()
Me.Stg_CustomerTableAdapter.Update(Me.AdventureWorksDataSet.Tables("stg_Customer"))


but it gave me an error (Update requires a valid UpdateCommand when passed DataRow collection with modified rows.)

i have inherited this style from the previous topic
however the thread is already closed so i started a new one.

please.your reply will be very much helpful...thank you
 
Just doing a simple Google search on the error message points to several different topics on how to resolve this.

Update requires a valid UpdateCommand when passed DataRow collection

Another way to look at it is to fill a DataTable with the records you need. Then attach it via the DataSource property of the grid. Make your changes, etc. Then iterate through the grid rows and execute an update manually. This is the method we use mainly on small to medium grids. Large data sets tend to be too taxing and we'll just address those on a "one-off" basis.

Good Luck.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top