views:

233

answers:

3

I need to retrieve the name of the stored procedure that a crystal report is running. Is there any way to do this in C# using the CrystalDecisions.CrystalReports.Engine.ReportDocument object?

I can't seem to find a property that will give me the stored procedure name.

Is this even possible? I've been through almost all the properties I can think of. The DataDefinition object has collections for the Formula, Parameter, Group Name, and Running Total Fields, but not one for the Database Fields.

Edit: I need to do this programatically, as I have a lot of reports. I need the option of skipping the actual running of the report and just executing the stored procedure that the report would have used. So when the report information is inserted into the database using the program, I want to be able to pull out its stored procedure and store that information separately.

A: 

Give this project a try: RptToXml.

Craig
A: 

You can use SQLServer Profiler to capture what stored procedure is being called when you run the crystal report.

First, you need to have the right privileges to run profiler.
Second, you need to start trace and immediately execute the report.
Third, stop the trace & scan to see the name of the stored procedure(s) the report executed.

SoftwareGeek
Thanks for the answer, but I actually need to do this programatically.
Brandon
Could you try opening the report itself in an editor like wordpad or xmlnotepad? Maybe that could have some metadata that you can search for the sproc.
SoftwareGeek
+2  A: 

You're going to kick yourself. The SP's are in...

ReportDocument.Database.Tables

DataBase

then Table.Location

Table

also don't forget about SubReports...which is another collection of ReportDocuments.

dotjoe
Thank you so much. You just saved me a lot of work, and I am kicking myself for not checking the Table object :P
Brandon