binding second form to same datasource

Richnl

Well-known member
Joined
Mar 20, 2007
Messages
93
Programming Experience
Beginner
Does anyone have the complete procedure to acomplish this?
I got part of it from a book ado.net core reference from David Sceppa, but I miss the samples.

It's about having the mainform display the datagridview while using the second form to change the details.

Sofar, what I have done is add a bindingsource component to the secondform and let it point to the dataset; set it's datamember to the table associated with the datagridview.

The individual controls point to the bindingsourcecomponent with the datamember set to a specific column.

Now it get's blurry
The mainform supposed to pass in an argument to a public EditDetail method in the second form so that the data from a specific row will be shown in the controls.
In other words, they have to be in sync.

How do I do that??

thanks in adv, Richard
 
Last edited:
I read a lot of tutorials, and a lot of the solutions in regards to relational data invalves creating custom sqlcommands or commandbuilder or something like that. They can't all be out of date, are they.

If they arent in the DW2 link, then they are either out of date, the wrong way or the hard way.

Updating related data is not rocket science. How would you do it in a stored procedure?
You'd update the parent data, then update the child data, in a transaction so it looked to have happened all at once. We havent touched transactions yet but lets walk before we run

I just google "update relational data ado.net" if I can't find it here.
Yes, but that wont help, because its not the right way to solve the problem You dont want to perform jsut one update to two sets of related data. You have 2 sets of data, that you assert are related, but the database doesnt care to see it that way. it jsut sees 2 sets of data and knows some rules for checking that a value exists in one table before you can add it to another table.. You still need 2 updates!

I started looking because when I wanted to save to the database this diddn't work
VB.NET:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000] If Validate() Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]Me.CustomersBindingSource.EndEdit()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]Me.OrdersBindingSource.EndEdit()[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]Remove rows childtable[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]Me.OrdersTableAdapter.Update(Me.myDataSet.Orders.Select("", "", DataViewRowState.Deleted))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Handle ; Add, Update, en Delete in  parent table[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' Me.CustomersTableAdapter.Update(Me.myDataSet.Customers.Select("", "", DataViewRowState.Added Or _[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]DataViewRowState.ModifiedCurrent Or _[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]DataViewRowState.Deleted))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Handle; Add, Update, en Delete in childtable[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]Me.OrdersTableAdapter.Update(Me.myDataSet.Customers.Select("", "", DataViewRowState.Added Or _[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]DataViewRowState.ModifiedCurrent Or _[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]DataViewRowState.Deleted))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]end if[/COLOR][/SIZE][/COLOR][/SIZE]

I'm not really suprised it didnt work.. have you seen it? Its horrendously complex!
 
still nothing, if I press the debug button, it loads the data - then I make changes, press the savebutton and reload the form again - I get the same data back without modifications?

Could be an entirely unrelated issue. Read the DNU link in my signature
 
I'm not really suprised it didnt work.. have you seen it? Its horrendously complex!
That's funny, no really, lol
It's my first experience with ado.net programming, so I am not familiar with best practice
I start out with code that just works, accumilated from everywhere and ofcourse I have that ado.net book containing redundant code.(see post 2 or something in that neaborhood):D

Could be an entirely unrelated issue. Read the DNU link in my signature
That's amazingly, Incredible helpfull.
It was setting me back for days....finally..haleluja

complements to that tutorial
Thanks Cjard
 
Last edited:
Back
Top