开发者

Finding the stored procedure that a Crystal Report is using

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 sep开发者_Go百科arately.


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.


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.


Give this project a try: RptToXml.


You can output the various properties of a Table with this code (sorry it's in VB, that's what I have to use for this project):

Private Sub logLogOnInfo(table As Table) log.DebugFormat("LogOnInfo.ConnectionInfo for {0}:", table.Name) Dim ci As ConnectionInfo = table.LogOnInfo.ConnectionInfo log.Debug(String.Format("AllowCustomConnection: {0}, DBName: {1}, IntegratedSecurity: {2}", ci.AllowCustomConnection, ci.DatabaseName, ci.IntegratedSecurity)) log.Debug(String.Format("ServerName: {0}, User: {2}, Password: {1}, Attributes:", ci.ServerName, ci.Password, ci.UserID))

For Each a As NameValuePair2 In ci.Attributes.Collection
    If a.Name = "QE_LogonProperties" Then
        Dim attributes As DbConnectionAttributes = a.Value
        For Each b As NameValuePair2 In attributes.Collection
            log.DebugFormat("        {0}: {1}", b.Name, b.Value)
        Next
    Else
        log.DebugFormat("    {0}: {1}", a.Name, a.Value)
    End If
Next

End Sub

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜