Solved

Setting Dynamic Path to Crystal Reports - RDC - VB

Posted on 2004-04-29
2
1,553 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
ID: 10951217
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
ID: 10951281
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now