Need help! db look up

GHost

New member
Joined
Feb 26, 2008
Messages
2
Programming Experience
Beginner
My task is to build a program that can store details of staff members that work at a company and also store details of the customers. I have built all the forms in order so that the user first enters the name of the staff member and reference code extra but I don’t understand the how I ‘attach’ a certain client with a certain staff member. I do have a database set up with VB.NET and I have got it to store details of the Staff and clients when entered in the forms and saved, all I now need to know is how, by using the reference key given to each Staff member, to ‘recall’ a staff member with all their details displayed on one form…

Please post any ideas……
I would be most great full
 
How do you plan to display the related fields on your form? Datagrid?

One thing that flags to me is that you mention you have a database set up with VB.Net.... I assume you mean a SQL database?

Have you specified relationships in your Database / Dataset?
 
Yes, I'm using a SQL database and I have specified relationships in the database. I want the data from the database to display the information in either a text box or combo box.
 
First of all, I recommend creating a DataSet based on your database, this will the thing that you databind to.

Once you have created a DataSet, if you click Data > Show Data Sources, then you will have a pane that contains all the tables and fields in the dataset, and you can then drag-and-drop the fields onto your form. VS will choose the control type that it thinks is most appropriate, or you can choose the field type.


Ok, so if I am right, on the customers form, you simply want a ComboBox to display a list of staff members, so that you can attribute that customer to a staff member?

In that case, all you need to do for the combo box is (obviously) add the combo to the form, and then on the smart tag, tell it to use data bound items.

The datasource should be set to your staff table, and the Display and Value members set accordingly.

Then, you should bind the SelectedValue part to your Customers.StaffID (or whatever field you have used).

I know this is all a lot to take in, and I would therefore recommend just concentrating on getting the forms set up with the TextBoxes first, so that you start to get the hang of ado.net 2.0 databinding. Leave the combo boxes until later.
 
Back
Top