Update datagrid

  • Thread starter Thread starter fabian
  • Start date Start date
F

fabian

I Apoligize for my writing but I speak spanish.
I'm starting with the datagrid and I want to know how I can to update
a datagrid after update a database. I want to do this without leave
the datagrid screen. I was doing with refresh and some more
instruction but I can't do it. Please help me.
 
Fabian,

I assume you are using a windowforms datagrid.

That you never update direct with code (you do it typing however I think
that is not what you ask).

In a windowforms datagrid you have always to update the datasource, which is
a datatable probably filtered by a dataview.

By the way there are a lot of non native English speakers active in this
newsgroup. So do not apoligize for your writing.

I hope this gives some ideas?

Cor
 
OK assuming that you are binding the datagrid to a dataset. Call the dataset
ds1, the dataadapter da1 and the datagrid dg1 and assuming that you have
generated the dataset using the wizard in the forms editor.

dim ds2 as new ds1
da1.fill(ds2)
dim dsChange as dataset
-------------------------------------
in form load---------------
dg1.datasource = ds2.mytablename


--------------------------------------
in a button_click event

dim dsChange as dataset

if ds1.haschanges then
dsChange = ds1.getchanges
da1.update(dsChange)
ds1.acceptchanges
end if
 

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

Back
Top