Crystal Reports in VS.NET 2005

For a client I had created a couple of records. Problem was that they another company had developed stuff in Access and I had to integrate with that flat file. The Access file was located on a network share. When I developed it was on my local disk and when I deployed my Typed Dataset objects were updated automatically. The crystal reports however didn’t get updated. After a long time I finally found a solution for setting the database location @ runtime.

CrystalReport1 rep = new CrystalReport1();
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo =rep.Database.Tables[0].LogOnInfo;
ConnectionInfo connectionInfo = new ConnectionInfo ();
connectionInfo = logOnInfo.ConnectionInfo;
connectionInfo.DatabaseName = "Database";
connectionInfo.ServerName = "Server";
connectionInfo.Password = "pwd";
connectionInfo.UserID = "uid";
rep.Database.Tables [0].ApplyLogOnInfo(logOnInfo);

There’s one stupid thing here. I had made my application so that I gave my report as string param. The application that woud look in the application path for that report. This way I could update my reports without redeploying. Unfortunately if you do it like this I didn’t find a way to access the tables of my report. The reportview seems to not give you the actual CrystalReport object when you load it from a string???

Well in in the end it works, that’s all that matters!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.