.NETGURU
Can I Join in code not stored procedure?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.distributed_apps.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Lori Markle via .Net Guru (VIP)
Hi All,

This is a 'why?' or 'Can I?' question.

I have an application I am using stored procedures and layers with.

I have an info layer (with private variables, constructors and properties), a data layer (functions with parameters) and a business layer(Gets). I am also using SQLHelper.

I am populating a part of the form using a join from a stored procedure.

The stored procedure says "get me all permit info from the permits table and the individual ID from the assignments table." I've changed my class PermitInfo to reflect the individual ID.

That works fine, except for the Division combobox. The stored procedure only has divisionID in it (from the permits table). I want the actual Division name to appear in the combo box, not the divisionID.

I know I can just add the division table to the previously mentioned join in the stored procedure, but I was wondering if there is a way I can combine the two in code, using their individual stored procedures (get permits, get assignments, get divisions) or something... Isn?t the point of multi-tier apps to leave the class layers and sql somewhat generic, to be used over and over again?

I have existing combobox logic that works for the Divisions when I want to see ALL divisions. I want to be able to do this when I bring up the permits:

1) look at the divisionID the permit stored procedure has put into the cbo box     THEN
2) look at the divisionID info from the existing Division combobox logic THEN
3) put the proper (matching) Division name into the cbo box.

Make any sense? Should I give up and just throw Division name into the stored procedure?

Here is my code:

Sub LoadPermitInfoFromIndividualID()
' firstlook to see if any fields in the individual form got filled in. IF so, populate proper fields in permit form.
Dim ClassPermit As New ParkingPermits.BizLogic.Permit
PermitInfo = ClassPermit.GetPermitByIndividualID(txtIndividualID.Text)

txtPermitNumber.Text = PermitInfo(0).PermitNumber
cboDivision.SelectedValue = PermitInfo(0).DivisionID 'need to add logic for division combo
dtpExpirationDate.Value = PermitInfo(0).ExpirationDate
cboStatus.Text = PermitInfo(0).status

LoadDivisionbyDivisionID()

End Sub

Below doesn't work, but is something like this possible?

Sub LoadDivisionbyDivisionID()
Dim ClassDivision As New ParkingPermits.BizLogic.Division
Dim ClassDivisionInfo As ParkingPermits.info.DivisionInfo()
ClassDivisionInfo = ClassDivision.GetDivisionByID(cboDivision.Text)

With cboDivision
.DataSource = ClassDivisionInfo
.ValueMember = PermitInfo(0).DivisionID
.DisplayMember = "Division"
End With
End Sub

Thanks for your help,
--------------------------------
From: Lori Markle

-----------------------
Posted by a user from .Net Guru (http://www.dot-net-guru.com/)

<Id>zVuyZ66h4UWRtXZWLmoz+Q==</Id>
Reply to this message...
 
    
richlm
You can do this using the DataRelation class together with a Dataset
containing your two (or more) DataTables.

The tables in the Dataset can be populated in a single round-trip to the
database by selecting multiple result sets, then set the relation.
There's a simple code sample in the class library reference for
DataRelation.

Richard.

Reply to this message...
 
 
System.Data.DataRelation




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification