OleDb DataAdapter Fill puzzle

R

rhino

Hi,

Working with ADO.Net/OleDb and Access2000. Using
dataAdapter1 to update Access table field and
dataAdapter2 to display the value from the same Access
data source.

Problem is, although dataAdapter1 is updating the Access
table (verified in Access), subsequent calls to the
dataAdapter2 Fill method do not refresh from the Access
source - the value coming out of the dataAdapter2 dataset
is always the same value - the one initially read on
application startup.

According to the documentation the Fill method should
refresh the dataset from the data source - but does it?
 
O

One Handed Man

Did you remember to bind the datasource/member of the control you want to
view the data to the dataset/table generated by DA2.

If so, is it generating an exception ( you didnt mention this )

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
W

William Ryan

Just as a thought, if you Bind the controls to the same
dataadapter, and you are sure updates are being submitted
properly, this will become a non-issue.
Without seeing the code, it's hard to see how this is
happening....and the timing of the update vs. the fill is
critical. If you know that the changes are showing in DA2
(since this is the one the controls appear bound to), then
how is DA1 know of these? You can just use one DataAdapter
to bind the controls, populate the Datatable/DataSet and
submit the updates. Using one is definitely the 'easier'
way to go... but if you have a definite reason to use two
of them (which you probably do), the timing of the events
is probably the problem.

Similarly, let's say that I fill a DataTable
Bills_DataTable and bind a grid to it

da.Fill(Bills_DataTable)
BillsGrid.DataSource = Bills_DataTable

Now, if I effect changes to the db without them happening
to Bills_DataTable, and I refill Bills_DataTable by making
Bills_DataTable a new table, those changes won't be shown
in the grid. However, it's hard to conceive of a way to
make those changes without hitting Bills_DataTable in the
first place, in which case the changes should be readily
visible. I'm rambling...


Anyway, can you show either the code or pseudo code of what
and when everything is happening? I'm sure we can figure
ti out from there.

Cheers.

Bill
 
R

rhino

Ok, I discovered that I had to first call the dataset
Clear method to remove all rows in the dataset table,
before calling the dataAdapter2 Fill method, otherwise it
seems that Fill appends rows to the dataset table -
rather than refreshing the original row. Since the data
was bound to a label only the original data was displayed.

Perhaps I should try to use one just data adapter, as you
suggest.

Thanks.
 

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