Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:57:38+00:00 2026-05-26T22:57:38+00:00

I am currently working on a program in C# that allows our users to

  • 0

I am currently working on a program in C# that allows our users to run, view and export a batch of Crystal Reports. The reports were made using the Crystal Reports 2008 GUI. One of the main reasons for doing this is to allow us to preserve hyperlinks when the Crystal Report is exported to PDF. My program does this by exporting to rtf, then converting the rtf to a pdf. If anyone knows of a less convoluted method of preserving hyperlinks when converting to PDf I’d love to hear it, but that’s not my current question.

I have done a lot of tests on how to optimize my program to make the export take as little time as possible. From what I’ve seen, having the application query for the data, then binding the resultset to the Crystal Report is by far the fastest method. My problem is that I can’t hard-code the queries into the program, they need to be retreived from the Crystal Report itself.

In Crystal Reports 2008, there is an option called “Show SQL Query” under the Database menu. This brings up a window with the SQL query used for the given report. This is exactly what I need to get my hands on from within my application. I’ve loaded a crystal report and, while debugging, traversed the ReportDocument object trying to find the query, but no luck.

So, my question is; is there any method available that would allow me to pull out the query used by a given Crystal Report?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:57:39+00:00Added an answer on May 26, 2026 at 10:57 pm

    Alright, so dotjoe gave me all of the hints that I needed to work this out. The following code can be used to pull the command text from a crystal report.

    public string getCommandText(ReportDocument rd)
    {
        if (!rd.IsLoaded)
            throw new ArgumentException("Please ensure that the reportDocument has been loaded before being passed to getCommandText");
        PropertyInfo pi = rd.Database.Tables.GetType().GetProperty("RasTables", BindingFlags.NonPublic | BindingFlags.Instance);
        return ((dynamic)pi.GetValue(rd.Database.Tables, pi.GetIndexParameters()))[0].CommandText;
    }
    

    It looks a bit messy, but it makes some sort of sense when you start wading through it. Basically, it uses reflection to get the value of the CommandText property, with a little dynamics thrown in to get past the dynamic properties in the ReportDocument.

    This is pulling the command text for me, but I have had no time to do any tests on the code. I’m sure I’ll be making some tweaks once I’ve had the time to work with this. I have no clue what happens with reports that do not use “SQL Commands”. I’ll post a comment once I’ve tested this further.

    • Scott

    P.S. This requires that you reference the standard reflection/dynamic libraries, as well as the following Crystal Report libraries:

    crystaldecisions.reportappserver.datadefmodel

    crystaldecisions.crystalreports.engine

    crystaldecisions.shared

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm working with a multi-threaded program (using pthreads) that currently create a background thread
I am currently working on a program that allows me to enter HTML source
im currently working in a simple program that implements plugins whith dll libraries (using
I'm currently working on a program that has many of those the user SHOULD
I'm working on a program that will sort files based on extension I currently
I'm currently working on a C++ program in Windows XP that processes large sets
Am currently working on an application that requires users to submit posts and comments
I'm currently working on a program that converts japanese characters to english characters and
I'm currently working on a program that analyses a wav file of a solo
I'm currently working on a tracking program which tracks hundreds of users at once,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.