Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data binding and multiple sql 2000 tables 1

Status
Not open for further replies.

hammertounge

Programmer
Jan 9, 2002
12
0
0
CA
I am working with a human resource database. There are three tables involved: employees, emergency contacts, and ratehistory. The primary key empid in the employee table is also a foreign key in the emergencycontacts and ratehistory tables.

My form has a list box bound to the employee table with the display member being the last name. I also have a series of text boxes listing the employee information. These textboxes are also bound to the employee table.

In the XML designer I created two relationships between the employee table and the emergencycontacts and ratehistory tables.

I created two datagrids on the form and bound them to the employee table and set the display member to the relationship between the tables.

Things are not working very well. Should I be binding to a dataview object instead of the table itself? Since all the bindings are done on the dataset.employee table I thought that the currency manager would handle it.

I could write all this in code but I thought the bindings would be quicker, any suggestions?

Thanks in advance.
 
Personally, I think writing it in code is much better. Since you'll have the ability to alter the way things cooperate. I always use code just to eliminate disgusting hatred toward objects. :)
 
What is "not working out well?" Is the relationship somehow causing things to load slowly? Is it now displaying the data? I have to agree with KraGie, personally I like to set my relations through code.

Here's an example that relates two tables in a dataset; I realize it might be a pain to read. Keep in mind that the datatables must already exist:

dsClaims.Relations.Add("Other Physicians", dsClaims.Tables("PrvHl20").Columns("PrvCode"), dsClaims.Tables("PrvOther").Columns("PrvHl20Code"))

dsClaims.Relations.Add("Enrollees for this Provider", dsClaims.Tables("PrvHl20").Columns("PrvCode"), dsClaims.Tables("SubHL22").Columns("PrvCode"))

dsClaims.Relations.Add("Patient relations for this Enrollee", dsClaims.Tables("subhl22").Columns("SubCode"), dsClaims.Tables("PatHL23").Columns("SubCode"))

dsClaims.Relations.Add("Claim for this Enrolle/Patient", dsClaims.Tables("SubHl22").Columns("SubCode"), dsClaims.Tables("Claims").Columns("SubCode"))

dsClaims.Relations.Add("Details for this claim", dsClaims.Tables("Claims").Columns("ClaimCode"), dsClaims.Tables("Details").Columns("ClaimCode"))

I then bind the dataset to a datagrid. This allows me to display the records in an hierarchical manner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top