Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting Dynamic Path to Crystal Reports - RDC - VB

Posted on 2004-04-29
2
Medium Priority
?
1,594 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:
Brendt Hess earned 2000 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 101

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 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