dataset not getting data of the the datagrid

A

anand

hi,
let:

dataSet1 is having some data from database.

dataView1 = dataSet1.table(0).defaultView
dataGrid1.dataSource = dataView1
[.. programatically construct a tablestyle for the grid ..]
dataGrid1.TableStyle.add(myTableStyle1)

ok, now i show the datagrid on a form. the use left clicks on a cell,
changes a value, and WITHOUT CLICKING ON ANY OTHER CELL OF THE
DATAGRID,
clicks a button on the same form.

on button click, i do:

if dataSet1.HasChanges(DataRowState.Modified) then
dataSet2 = dataSet1.GetChanges(DataRowState.Modified)
end if

the problem is that dataSet2 has a table with one row, the row which
the use had clicked, BUT WITHOUT THE CHANGED DATA. it contains the
same old data with wich the grid was loaded initially.

is there any way out of this problem ? i need the changed data.
i have tried dataGrid1.refresh et.al....

saha
--
 
C

Cor

Hi Anand,

I think you do a lot more than needed, but start with to try this before
that haschanges.

BindingContext(dataset1.tables(0)).EndCurrentEdit()

I hope this was the solution?

Cor
 
J

james

First question, if you re-connect to the database are the changes your user
makes, actually being written back to the database? If not, then that is
the reasons your changes are not showing up. I ran into the same problem
with an Access Database and got so frustrated that what I finally did (which
is not the "proper" way to do it) was to just re-connect to the database
AFTER deleting the current row that was being edited and adding it back to
the database as a NEW datarow. A very ugly work-around, but it works. I am
currently in the proccess of fixing that as that is not the way it is
supposed to work.
If you are using a DataAdaptor to get to your database, be sure you are
refreshing it too.
james

(I'm almost ashamed to post this, but, I understand the frustration of
working with Access Databases in VB.NET)
 
A

anand

Cor said:
Hi Anand,

I think you do a lot more than needed, but start with to try this before
that haschanges.

BindingContext(dataset1.tables(0)).EndCurrentEdit()

I hope this was the solution?

Cor

hi Cor,

i could solve it this way. before doing a dataset1.haschange, i did:

For Each cs As DataGridColumnStyle In
dataGrid1.TableStyles(0).GridColumnStyles

dataGrid1.TableStyles(0).EndEdit(cs,
datagrid1.CurrentCell.RowNumber, False)

Next

then after doing a dataset1.haschange and before dataset1.getchange, i
did:

Dim rowIndex As Integer
rowIndex = baseDataGrid.CurrentRowIndex
dataGrid1.CurrentRowIndex = 0
dataGrid1.CurrentRowIndex = rowIndex

dataSet3 = dataSet1.GetChanges(DataRowState.Modified)


it worked! the trick is, i think, that the changes appeared in
dataSet3 after i changed(shuffled) the row index of the datagrid.
thanks for the hint.

saha
--
 

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