Solved

Setting Dynamic Path to Crystal Reports - RDC - VB

Posted on 2004-04-29
2
1,546 Views
Last Modified: 2012-06-27
OBJECTIVE:
I want to set the database path of crystal reports dynamically at run time and refresh the data based on the dsn connection.

DETAILS:
I have to use multiple databases in a project. Back end is MSAccess and Front End VB. The connection to the database is done using ODBC automatic dsn code. The reports are desinged

using CRViewer(RDC). The structure of all the databases are identical and only the stored data is different (For example sale details of current year in a database and the previous financial year in another database and so on.)

In the application, the connection to the particular database is done by selecting the available database and then making a dsn connectoin to the selected database at run time (using automatic dsn code).

Thus When the database path is changed dynamically, the new set of data from the latest database connection is to be refreshed in the crystal report. How can this be achieved?

0
Comment
Question by:r_venkatadhri
2 Comments
 
LVL 32

Accepted Solution

by:
bhess1 earned 500 total points
Comment Utility
In CR, an ODBC connection is more difficult to change than many.  The method that I know of is:

Get the report tables
    Set CRXTables = CRXReport.Database.Tables  

Get the individual tables
    Set CRXTable = CRXTables.Item(1)

Finally, set the location of the .mdb file.
    CRXTable.SetLogOnInfo <ODBC_DSN>, <databasename>, <userid>, <password>

You may need to do this for all subreports as well separately (I don't use DSNs on a regular basis, so I don't know for sure)

If you are trying to make a DSNless connection, I would use ADO instead.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Agree with bhess1.

Another thing is make certain the reports are saved with data.

Open a report
Click FILE
Ensure SAVE DATA WITH REPORT is not checked.

You can also add a line like

crRpt.DiscardSavedData to your application.

mlmcc
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now