By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

Need to create link between DataSet tables to show matching records

P: n/a
My program has to tables in it. One is the Accounts table with all
personal information and then there is also my Memos table with all the
notes for each account. My program displays one record at a time for
each account in the dataset table. I now want to show only the notes
in the memo file that match with the Accounts table current Account #.
I have done some similar to this in Access with a subform linked by
account # to account # and it worked great, just need the same ability
in this application.

Nov 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
How does your program show the data? Is it in a grid?

You could do a master/detail grid where the top shows the
Accounts and the bottom shows the Notes that go with the
currently-selected Account. Is that what you're aiming for?
Or are you just trying to get the memo information out
of the DataSet?

Robin S.
--------------------------------
"mike11d11" <mi*******@yahoo.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
My program has to tables in it. One is the Accounts table with all
personal information and then there is also my Memos table with all the
notes for each account. My program displays one record at a time for
each account in the dataset table. I now want to show only the notes
in the memo file that match with the Accounts table current Account #.
I have done some similar to this in Access with a subform linked by
account # to account # and it worked great, just need the same ability
in this application.

Nov 22 '06 #2

P: n/a
Right now I have my Account Detail table showing each field on my form
in individual text boxes. I would probably be good to have the notes
part show up in some sort of DataGrid at the bottom, so they can add
additional notes to that record. Any ideas on how I can do this would
be great?

Nov 22 '06 #3

P: n/a
Yes and I only want the notes for the current account showing up in the
Memos Grid at the bottom. And it has to have the functionality of
adding additional notes for the current account.

Nov 22 '06 #4

P: n/a
Is the data for the account bound? So you have a bunch
of textboxes and that info is bound, and then you can
show a grid down below for the notes?

Are you using SQLServer as your data source?

Robin S.
--------------------------------
"mike11d11" <mi*******@yahoo.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
Yes and I only want the notes for the current account showing up in the
Memos Grid at the bottom. And it has to have the functionality of
adding additional notes for the current account.

Nov 22 '06 #5

P: n/a
Yes data in the text boxes are bound to the WorkList table. My data
source is SQL 2000 server.

Nov 22 '06 #6

P: n/a
Okay, generally, you have one dataset with both of the
tables in it. Then you need to set up a binding source,
and set the data member and data source
of your controls accordingly. Here's an example.

I don't know how you are creating your dataset. I am
going to assume you created it with the DataSetDesigner?
Or are you creating it on your own? If you're creating
it on your own, that's a different ball of wax, because
you have to handle the relations on your own.

I have a dataset that has two tables: Customers and Orders.
(This runs against Northwind, so if you have that
installed, you can try this out.)

I set up a strongly-typed dataset using the Data Set
Designer with both of those tables in it, and there is
a field called CustomerID in the Orders table that links
to the CustomerID table in Customers. So Orders have a
Customer as a parent. The data relation between
the customer and the orders is defined as FK_Orders_Customers.

This is in Form_Load:

'First, populate the dataset.
Dim nwData As CustomersDataSet = CustomersDataSet.GetCustomers()

'Set the data source for the binding source to the dataset.
CustomersBindingSource.DataSource = nwData
'Add this so it knows which table to use .
CustomersBindingSource.DataMember = "Customers"
'Set the data source for the grid to the customers binding source.
CustomersDataGridView.DataSource = CustomersBindingSource

'Add the binding for the child; set its binding source to the same
' one as the parent.
Customers_OrdersBindingSource.DataSource = CustomersBindingSource
'Set the datamember to the foreign key joining the two tables.
' You can see this on your CustomersDataSet diagram.
Customers_OrdersBindingSource.DataMember = "FK_Orders_Customers"
'Set the data source on the child grid to points at its binding source.
OrdersDataGridView.DataSource = Customers_OrdersBindingSource

AddTextBoxDataBindings()
AddComboBoxDataBindings()

Here are the routines that bind the textboxes and combo box
in case you want them.

Private Sub AddTextBoxDataBindings()
'Bind each text box to the appropriate field in the
' CustomersBindingSource
CustomerIDTextBox.DataBindings.Add("Text", _
CustomersBindingSource, "CustomerID")
ContactNameTextBox.DataBindings.Add("Text", _
CustomersBindingSource, "ContactName")
CompanyNameTextBox.DataBindings.Add("Text", _
CustomersBindingSource, "CompanyName")
ContactPhoneTextBox.DataBindings.Add("Text", _
CustomersBindingSource, "Phone")
End Sub

Private Sub AddComboBoxDataBindings()
ContactsComboBox.DataSource = CustomersBindingSource
ContactsComboBox.DisplayMember = "ContactName"
ContactsComboBox.ValueMember = "CustomerID"
End Sub

Hope that provides enough info. This information
came out of Brian Noyes's book on Data Binding.

If you want to do updates, let them change the data in the
grid, then call the Update method on your table adapter:

CustomersTableAdapter.Update(ds)

I think that should work. Good luck.

Robin S.
-------------
"mike11d11" <mi*******@yahoo.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
Yes data in the text boxes are bound to the WorkList table. My data
source is SQL 2000 server.

Nov 22 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.