DataGrid updates in Windows Forms - Am I going crazy?

DataGrid updates in Windows Forms - Am I going crazy?

Post by Logicia » Mon, 18 Jun 2007 01:57:52

I am trying to just load a datagrid and save the changes. I have
googled and sweated over this, and thanks to Microsoft I have much
pain. Can anyone help?

I am populating the DataGrid with NP, using

DataSet thisDS = getDS(thisDBName); // returns dataset based on an SQL
DataGrid1.SetDataBinding(thisDS,"Part"); // put data into datagrid

That works fine. But when I try and update, I keep a jumble of errors.
The basic issue is that my grid that is defined at design time and
populated via an SQL query (above), has no DataSet as a source in grid
properties. So I need some code to pull out the data from the grid.

I tried getting the design time oledbadapators working, but I got

Google is great, but you find you keep hitting the same pages on
different searches.

Can anyone help? What I need is just some simple code for Windows
Forms using mdb files to populate the datagrid using joins from tables
and then update values. I would like also to put some drop down boxes
in the cells. I can this on my Web server using dataitems.

Anyway, my head hurts and I feel like I am running a small circle!
Also I starting to think google really only 10 pages in its index and
the rest are spoof pages!

DataGrid updates in Windows Forms - Am I going crazy?

Post by Nicholas P » Wed, 20 Jun 2007 03:16:29


The thing you have to realize is that what you are showing in the grid
is completely disconnected from the underlying data source. When you call
SetDataBinding, the DataSource and the DataMember properties are set
appropriately. You can get the underlying dataset from the DataSource
property, in this case.

Once you have that, you can pass the dataset to an OleDbDataAdapter
(which you will have to set up based on the underlying data) so that you can
update the underlying tables.

- Nicholas Paldino [.NET/C# MVP]