Wednesday, March 28, 2012

Report with Multiple Data sources: Can I do this?

Okay, so I have this ADO.NET dataset defined in my project. I created
an RDLC report and from the menu Report->Data Sources... I chose two
different tables that exist in my ADO dataset. So far so good. At this
point I can drag specific columns into various text boxes I have in my
report (I'm not using tables) and I end up with entries like
"=First(Fields!ContactName.Value)". That's all well and good, but what
I was hoping to do, in addition to that, is something where I can
specify a particular record from one of the tables. Basically what I
have is a table that has two different links to another table. Now
each of those links may be to the same record, or to two different
records. I have a "Job" table and a "Company" table. The Job table has
a link to a "Dealer" and an "Installer" (both of which are records--or
the same record--in the Company table). I was hoping to be able to
display the installer name in one text box and the dealer name in
another. I have two issues: I don't know how to refer to a specific
table when referring to a particular field (both the Job and Company
tables have a "ContactName" column), nor does there appear to be a way
to pick a particular record. I can't seem to be able to do something
like "=Fields!Job.ContactName.Value" when I want to refer to the
ContactName in the Job table as opposed to the Company table. Further,
I can't figure out how to do something like (kinda pseudo code here)
"=Fields!Company.ContactName WHERE Company.ID == First(Fields!
Job.InstallerID.Value)"
So it comes down to this: Can I do anything like what I have described
above? If I can't, my next thought it to create a stored procedure
that gets every value I need and stores it in a custom named field so
I have JobContactName, InstallerContactName, etc to refer to, but then
my next question is can I define a stored procedure that will let me
grab the data I'm looking for from my in-memory ADO.NET Dataset?So I discovered that using subreports would solve my immediate
problem, but I'm still curious if there is a way to do some of what I
describe above, which is: access each different datasource via Fields,
and access specific rows in that source. Right now we can access First/
Last and what ever is chosen as the default when you don't specify
First or Last, but why can't we access a specific record based on the
value of a field in that record? I just want to know if any/all of the
above is possible or not, and if not, what are the patterns people
follow to get around these limitations?
Thanks!

No comments:

Post a Comment