cancel
Showing results for 
Search instead for 
Did you mean: 

cannot get SQLQueryString from crystal report if no database connection..

Former Member
0 Kudos

Hi,

I am using craxdrt.dll to create a crystal report object.

I want to get the SQLQueryString used in crystalreport even if i dont have databse connection or even database on my local computer.

How can I do this?

Is there any other way to do this without connecting to database?

I just want to read its SQLQueryString Property.

Please Help me.

I am in need of it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think we can get sqlquerry if not connected to database.

If you want query save your report with saved data.

Check one thing:

Do a small test to test your connection.

-Right Click on desktop ->

Create new text document->

Save as test.UDL->

double click and test connection by selecting driver name,datasource name,user id and password.

Click on Test Connection.

It should be succeed.

Regards,

Shweta

Former Member
0 Kudos

Thanks for reply,

But i dont want to check my connection to database.

I want to get querystring from any arbitrary RPT file, even which is never executed on my machine with database connection.

do i need any special DLL?

I am using CRAXDRT.DLL right now.

former_member183750
Active Contributor
0 Kudos

Try this:

u2018Declare a string variable to hold the SQL Query

Dim strSQL As String

u2018To retrieve the SQL Query

strSQL = Report.SQLQueryString

u2018To pass a SQL Query

Report.SQLQueryString = strSQL

You do not mention what version of CR you are using and the database engine was rewritten in CR 9 so I am not sure if the above will work with CR 9 and above.

Ludek

0 Kudos

Crystal dynamically generates the SQL depending on the DB you are connected to, so CR will not allow you to get it with connecting first.

You can't view the SQL in CR Designer either unless you first connect to a Database.

Why do you want it, possibly we can come up with a work around?

Thnak you

Don

Former Member
0 Kudos

Thanks for reply, but i am not still getting answer to my question.

My clear question is that :

How can i get query from crystal report file if i dont have database used for that report?

I can get list of database,tables,fields etc.

but how can i extract query exactly used for that report?

Do you have any idea about it?

Thanks again.

former_member183750
Active Contributor
0 Kudos

My clear question is that :

How can i get query from crystal report file if i dont have database used for that report?

I can get list of database,tables,fields etc.

but how can i extract query exactly used for that report?

- I think Don's reply in his post is clear:

Crystal dynamically generates the SQL depending on the DB you are connected to, so CR will not allow you to get it with connecting first. You can't view the SQL in CR Designer either unless you first connect to a Database.

Ludek

0 Kudos

The Clear answer is NO, as I said, only way to get the SQL is to connect to a DB of some type.

As a work around you can get the SQL if you have a dummy database to connect to. But you do need to know what type the report was designed off of or you take the chance of getting incorrect SQL. We can help you a bit here. Using the RDC you can get 2 DB types:

crSQLDatabase or crStandardDatabase, first one is if the report was designed off a SQL database like

MS SQL Server or Oracle etc and the second one is if it's based on a PC type like Access or Dbase. Although if it is PC based there may not be any SQL to get unless the PC DB supports SQL queries. If they don't then no SQL can be returned.

Is there a specific reason why you need to get the SQL?

Thank you

Don

Answers (0)