Re-post, Help really needed here ! Dataview binded to Textbox for edits, I can't save the change.

M

Marc R.

Happy new year everyone,

Back from vacation, and here's a new Chalenge for "moi".
I got 2 Dataview.
1 for DVsupplierSearch that is bind to a grid
1 for DVSupplierDetails, that is bind to several TextBox for Edits
Both are views from SupplierTable in same Dataset.
Went I edit the Textboxes, the grids takes the edited information correctly,
but I cant find a way to comit those change to DB.

Why I got 2 datasets :
DVSupplierDetails binds to current seleted row into grid

Thanks for tips.

Marc R.
 
M

Marc R.

Marc R. said:
Happy new year everyone,

Back from vacation, and here's a new Chalenge for "moi".
I got 2 Dataview.
1 for DVsupplierSearch that is bind to a grid
1 for DVSupplierDetails, that is bind to several TextBox for Edits
Both are views from SupplierTable in same Dataset.
Went I edit the Textboxes, the grids takes the edited information
correctly,
but I cant find a way to comit those change to DB.

Why I got 2 datasets :
DVSupplierDetails binds to current seleted row into grid

Thanks for tips.

Marc R.

Here is the code I have what is wrong ? I have tried to accept change all
possible way I could think of, but the DataAdapteur.updates will not make
the change

Me.DVSuppDetails.Table.AcceptChanges()
Me.DsAdmin1.Tables("fournisseur").AcceptChanges()

Me.DVSuppDetails.Table.DataSet.AcceptChanges()

da_Supplier.Update(Me.DVSuppDetails.Table)

da_Supplier.Update(DsAdmin1)
 
G

Guest

Marc,

AcceptChanges should be called after the data adapter's Update method, not
before.

Kerry Moorman
 
M

Marc R.

If I do So, it doesn't even show the change into the grid. AND it is still
not saved. (into Database)
 
C

Cor Ligthert [MVP]

Marc,

Set an endcurrentedit instead of your acceptchanges. The endcurrentedit
pushes the data from the grids to datasources.

\\\
BindingContext(ds.Tables(0)).EndCurrentEdit()
///
The ds.Tables(0) has to be what is the datasource of your datatagrid

The acceptchanges is with an original datatable done by the update command.

I hope this helps,

Cor
 
M

Marc R.

Sorry Cor, I'm realy new at .net ... bindingcontext mean ?

I will try to explain how my stuff is build :

Grid supplier :
datasource : DVSupplier (DataView on which I build rowfilter condition
from a quick questionaire)
TextBox txtSupplierName :
datasource : DVSuppDetails (on Grid_Supplier.click I take Selected row
supplier_ID and build a RowFilter for DVSuppDetails Wich fills all my txtbox
for edit.)

On each of my txtbox :
evenHandler "Enter and leave" have beguinedit and endEdit on the only
dataRow that DVSuppDetails may containt.

Ofcourse I need the grid to accepts my change from the texte box but more
importantly, I need to have the change in SQL server.

I will keep looking, for that hint,

BTW, sorry if my english is not that good, I'm a french person. I do my
best.

Marc R.
 
C

Cor Ligthert [MVP]

Marc,

Just do it with both datasources. The bindingcontext is a collection of all
databindings you have set.
You tell than that it has to do the actions as if all things are done.

In a simple datacontrol (by instance textbox) the data is pushed as soon as
the cursor goes to another control. In a complex one (grid) if it goes to
the next row.

If you use a button to update or whatever than the data stays in the
control.

Try this ones.

BindingContext(DVSuppDetails).EndCurrentEdit()
BindingContext(DVSupplier).EndCurrentEdit()

The acceptchanges set all the rowstate indicators, that all changes are done
at the database and therefore you can never update it if you do that before
the update.

I hope this helps?

Cor
 
M

Marc R.

Thanks Cor,

Now It does save into DB, but still not updating the grid went leaving the
Textbox but I'm sure I will find out before you have time you reply,

thanks a lot,
 
M

Marc R.

Hi Cor,

once more sorry for such stupid question.

Seems that I can't update the grid right away I need to leave the textbox
then come back into it that leave again to have the Grid updates, Got any
idea why ?
 
Top