Joined: 17 Mar 2007
Online Status: Offline
Posts: 16
Topic: Deploying Applications with CR and Access 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 ;-)
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
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>
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum