[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Crystal Report Database Query

Posted on 2003-12-10
15
Medium Priority
?
601 Views
Last Modified: 2007-12-19
I would like to be able to change the query of a Crystal Report on the fly.

I have the query built into a command in the designer at the moment.

Can any one help me?
0
Comment
Question by:Terry Rogers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9913049
I'm not sure what you mean by 'built into a command'

However, in Visual Basic, add references to the Crystal libraries (Project/References), that will get you started. It allows you to change various properties of a crystal report and then run it.
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9913180
ok, Im using a Crystal Report designer within my VB app.

When I click the designer it shows me the design of the report.

On the left it says "Database Fields" and under this is "Command" with the Fields from the "Command" SQL Statement coming off of it.

If I go into the database expert I can see on the right the server address and under that another item called command which I created with my SQL query in. To edit the sql query in that command I right click on it and select edit command.

I need to be able to edit this command from within my VB code and not the designer.

Hope ive made things a little more clear.
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9913497
Ah, OK, I am using the full version of Crystal rather than the VB version at the moment so I got a bit confused, sorry.



This will work in theory but I avoid the data environment so I haven't used it much.

DataEnvironmantName.Commands("CommandName").CommandText = "New SQL Query"

Make sure the query returns the same number of fields and ensure they have the same names.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9913557
Oh yeah, now that I have had a hack, the command has to be a SQL statement rather than a table, otherwise that will just change the table name rather than the whole SQL statement.
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9914453
This is good except im not using a data environment, so how can I change the command in the report?

My designer is called CrystalReport,

And I dont have a CrystalReport.Commands options, I have a CrystalReport.Database but I still cant find the command thing your referring to.
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9914522
I have found that CrystalReport.SQLQueryString is holding my query but when I try to change it it doesn't change.
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9914543
Also im using Crystal Reports 9 if thats of any help.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9917663
What you are trying to do may require the Crystal Reports 9 Designer Design and Run Time library (CRAXDDRT.dll).  This may also incur a requirement for you to purchase runtime licenses for all users ($199 per license).  

In general you cannot change the select part of the query.  It may be possible with the CRAXDDRT library.

mlmcc
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9918820
This has come from CrystalDevHelp.chm.

Property: SQLQueryString
Description: String. Gets or sets SQL query string.
Read/Write: Read/Write
Restriction in event handler: Can be written only when formatting idle.

It seems this is what I need to change, and it is a read/write property. But how can I make "formatting idle"?
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9918910
Formatting Idle sounds lke it means you can only change it when the report is not running, which is what you are doing anyway.

Sorry I will have to bow out as I only have version 7, and I can't find the crystal reports designer option in VB.

There is one other option and that is to base the report on a view (A SQL Server view or a MS Access query) then change the view in the database. It's a bit hairy though and really you shouldn't have to if Crystal help says you can change the source query.

Good Luck!

0
 
LVL 1

Expert Comment

by:vbnewby
ID: 9919443
This may not be the correct answer to your question, but it is the way I have got around it.

I first created a report table in the database, had my SQL statment populate the report table, then had crystal report look at that table



0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 9919988
vbnewby, this seems like a solution but it seems a bit long winded.

Anyone, anyone at all who can come up with a good solution to this problem would be great.

getting more and more desperate by the minute. :-\
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9920215
Like I said there is the view option but it is also a little bit long winded.
0
 

Accepted Solution

by:
SerCouWisMOD earned 0 total points
ID: 9966975
A request has been made to close this question and refund the points;
http://www.experts-exchange.com/Community_Support/Q_20829593.html
If there are no objections within the next 72 hours, the request will be granted.

EXPERTS: Please leave your thoughts on the request here.

SerCouWisMOD
Community Support Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question