Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Access a DataSet from Custom Code?

Author  Topic 

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-04-18 : 18:58:41
Any ideas how (if at all) I can access one of the DataSets that already exists in my report from within custom code? I know I can pass arguments into my custom code, but I'd like to extract something from a DataSet.

Here are more specific details, and if you have a totally different approach to solving the issue, I'm open to suggestions... My report has 3 datasets. One that produces the report details, and two that are used for parameter drop-down lists. The drop-down lists and report are all working just fine to produce the correct report. Imagine that one of the drop-down lists is for company department, containing a key value and a department name. In the Page Header section, I am able to use the Parameters collection to display the selected department key value, but I'd rather display the department name (reports are run for one department at a time only). Any ideas how I can get that department name text?

-----------------------------------------------------------------------------------------------
Emerald City Domains: Great deals on Domain Registration, Web Hosting, Custom Email, and more!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-18 : 19:02:38
Well, I've done this by adding the information to the data set. So even if every row will contain the same department name, I include it there and just grab the TOP one. You could also do this via a .NET assembly and link the assembly to the report. We only go down that route though when there's a lot of calculations being done.

Tara
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-04-18 : 19:23:44
I agree going the .NET assembly is a lot of headache for this little task. And unfortunately, since I'm using the actual Page Header section, it complains if I reference a Field, even doing a First on it.

Now, I've seen you suggest in the past to avoid that section and use grouping instead, but what I ran into with that was that when we export this to PDF, the Repeat With did not actually make it repeat. (Note that this is using a List in the detail section, not a Table. Have you had better luck with Table objects actually repeating properly when exported to PDF?)

I do have the option, since I have a front-end web app leading into the report, I could pass in the desired text as a dumb parameter, but I'd rather make the report fully capable independent of our front-end.

Any other ideas? I have not found any documentation that gives a hint about possibly being able to access the DataSets from within custom code, that just seems to be my wishful thinking. Anyone have better luck?

-----------------------------------------------------------------------------------------------
Emerald City Domains: Great deals on Domain Registration, Web Hosting, Custom Email, and more!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-18 : 19:28:21
We've had all sorts of problems exporting to PDF but I don't recall it having to do with the repeat option.

I am pretty sure that the custom code piece is only able to get data from what was passed into it. I've seen others here have problems with fields so I'm guessing that parameters or data sets will give you the same problem.

Jon (jhermiz) might be able to offer another suggestion as he's the other person that I know of using RS a lot. He's come up with some interesting hacks/work-arounds for Chriskhan2000.


Tara
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-04-19 : 10:28:38
Hey Mark,

If you create a table rather than a list you should be able to enable the Repeat With option. One of the nice things about a table is you can make it look like or act like a list object. I try to avoid the list because RS has some funky exporting results when you export a list to pdf. I have heard most of these "bugs" are going away. Also if you include the data in the actual data set (INNER / LEFT / etc. JOIN) than you can retrieve the actual text rather than the key information. I know you said you get some error but I just tried it out on a basic example with a Customer and a CustomerID and I used FIRST(Customer) and it worked well. The data may repeat but there is not much you can do about it but to rely on the RS grouping capabilities.

Finally, the only other option you have is what tara had stated, that is to create and reference an external assembly. You can call both instance and shared methods when using custom code. If you are using shared methods it is much like static objects in C++ / C#:

Namespace.Type.Method(args)

So what you could do is create your own assembly(dll) which returns the text value of a specific key, kind of like a hash table:

=Blah.RSLib.GetTextFromKey(yourCustomerID)

Blah is the assembly RSLib is the type the method is GetTextFromKey and you would pass the Parameter object collection property that is available to you (Which you are currently getting from the report) as the argument. It is kind of a lot of work for what you are looking to do, but if you plan to do this a lot you can reuse the assembly.

I would definately change the report from list to table as a start though.

Jon





Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-04-19 : 12:05:29
Jon,

Thanks for the feedback. To make sure we're talking the same thing, I'd like to emphasize that the Repeat With option works fine in the default RS rendering. It's just when exporting to PDF that it only shows up once (does not repeat). Also, to be sure we're talking the same thing, were you able to get the FIRST(field) to work in the Page Header section of a report? The Page Header and Page Footer are really picky about referencing any fields.

There's no way I could justify introducing an assembly for just this. If all else fails, I'll fall back on the dummy parameter passed in from the front-end, but I really don't like my report being dependent like that.

I am in the process of testing a table conversion and that may take care of it. It's a shame there's not a better way, but I guess this essentially is a version 1.0 product, so it's doing really well for that.


-----------------------------------------------------------------------------------------------
Emerald City Domains: Great deals on Domain Registration, Web Hosting, Custom Email, and more!
Go to Top of Page
   

- Advertisement -