3 Replies - 38125 Views - Last Post: 06 April 2009 - 04:45 PM Rate Topic: -----

#1 exiled  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 03-February 09

How to save ALL changes made in DataGridView to Access database

Posted 03 February 2009 - 10:55 AM

I use a DataGridView to Add/Edit/Delete records from an Access database. Doing those 3 things is working just fine. When I try to update the database with the new Table data, nothing happens. I need to basically overwrite the table in the database with the data that was added, edited or deleted in the DataGridView. I opened the connection and got the table data like this:

	Dim con As OleDbConnection = New OleDbConnection(source)
		PartsAdapter.SelectCommand = New OleDbCommand("SELECT " & PtsSql & " FROM Parts", con)
		comBuilder = New OleDbCommandBuilder(PartsAdapter)
		con.Open()
		PartsAdapter.Fill(PartsTable)
		D1.DataSource = PartsTable



and have tried for several days to get the data from DataGridView to save. The last code I used (and it failed) was this:

		Dim myDt = New DataTable("PartsTable")
		Dim myDataSet = New DataSet()
		myDataSet.AcceptChanges()
		PartsInventory.Update()



Surely there must be a way to save the edited data from a DataGridView back to the table in the database!?! Any help would be appreciated! Thanks!

This post has been edited by exiled: 03 February 2009 - 10:57 AM


Is This A Good Question/Topic? 1

Replies To: How to save ALL changes made in DataGridView to Access database

#2 exiled  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 03-February 09

Re: How to save ALL changes made in DataGridView to Access database

Posted 03 February 2009 - 10:13 PM

***** RESOLVED IT MYSELF *****
Was This Post Helpful? 0
  • +
  • -

#3 almcnicoll  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 09

Re: How to save ALL changes made in DataGridView to Access database

Posted 05 February 2009 - 09:13 AM

View Postexiled, on 3 Feb, 2009 - 09:13 PM, said:

***** RESOLVED IT MYSELF *****


I have run into exactly the same issue. I tried using Andrew Timberlake-Newell's code (http://www.codeproje...ingBoundDB.aspx) which uses a boolean to store when data is dirty and then runs
myTableAdapter.Update(myDataSet.myTable)


on the datagrid's OnRowValidated event.

No joy. Would you mind sharing how you resolved the issue?

(By the way, I'm using an Access 2003 DB, coding with VS.NET 2008)

Al
Was This Post Helpful? 0
  • +
  • -

#4 zbora23  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 57
  • Joined: 26-February 09

Re: How to save ALL changes made in DataGridView to Access database

Posted 06 April 2009 - 04:45 PM

hi guys i finally have resolved that problem this is code for that
Me.myTableAdapter.Update(Me.myDataSet.myTable)


That is code for that i don't know if it is necessary to use '' Me. '' instead of nothing.
All you have to do is finish editing row, so enter all data trough all columns and on the last column after filling it out press ' TAB ' key and then save it
Data will save it then.Otherwise if you don't finish editing entire row it wont save.
if you don't know how to do it send me email on zbora23@yahoo.com , I'll send you movie with instructions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1