DataGrid updates in Windows Forms - Am I going crazy?

L

Logician

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
query
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
nowhere.

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!
 
N

Nicholas Paldino [.NET/C# MVP]

Locigian,

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top