Print Page | Close Window

Deploying Applications with CR and Access

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=341
Printed Date: 29 Apr 2024 at 11:25am


Topic: Deploying Applications with CR and Access
Posted By: pooba53
Subject: Deploying Applications with CR and Access
Date Posted: 17 Mar 2007 at 5:23pm
I'm looking through chapter 17 of "Crystal Reports .NET Programming" and must be blind. Here's the problem:

1. My report is working great and printing out just fine with my VB .NET/VS 2003 application. I used the report wizard to set up my report initially and it knows the Access db is at c:\databases\data.mdb.

2. When I deploy my application to users, the Access db gets put in the directory where the executable resides. From within VS 2003 this would be:

AppDomain.CurrentDomain.BaseDirectory

3. The problem is, I do NOT know how to set the connection string to the above location at runtime for CR to know where to find the location of the Access databse.

It's still looking for the location to be c:\databases\data.mdb!

I'm assuming that if I have instantiated a report (MyReport), there must me a clever way of changing the db location and I'm too stupid to figure this out. I was able to figure out how to do this with my Access database connection string so I'm not a total moron ;-)



Replies:
Posted By: BrianBischof
Date Posted: 17 Mar 2007 at 7:00pm
Yes, changing data sources can be very confusing. In fact, just on Friday a girl at my office was having the same problem and she had my book open right in front of her. The problem is that there are so many options to choose from that it can get confusing knowing which one to pick. For the next edition I'm going to really make it painfully obvious how to do it.

For your question, look at pages 363-365.  Try to copy Listing 17-4 to your app and call it. The key for Access is that the filepath goes in the ServerName property and not the DatabaseName property. The DatabaseName property is the empty string.

Also, the problem that girl had at work was that she was mixing up two different listings in the book. She was trying to assign parameters with the ReportViewer object and assign the database connection with the ReportObject object. You can't cross the two objects. You can only use one object to set properties, otherwise one will overwrite the other and completely screw you up.

Hope this helps


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: pooba53
Date Posted: 18 Mar 2007 at 3:29pm
Looks like this snippet from the Business Objects Web site did the trick:

dbPath = AppDomain.CurrentDomain.BaseDirectory & "data.mdb"

Dim MyReport As New CrystalReport1
            Dim CrTables As Tables
            Dim CrTable As Table

            CrTables = MyReport.Database.Tables

            For Each CrTable In CrTables
                CrTable.Location = dbPath
            Next

Everything is now groovy.



Print Page | Close Window