Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Crystal Report.net with Access 2003 Post Reply Post New Topic
Author Message
vinumpillai
Newbie
Newbie


Joined: 27 Jan 2009
Location: India
Online Status: Offline
Posts: 1
Quote vinumpillai Replybullet Topic: Crystal Report.net with Access 2003
    Posted: 27 Jan 2009 at 1:38am
Dear Friends
I have an application using MS Acess Database. the application is developed using VS.net 2008. My problem is the location of the access database. When i deploy the appliation to another PC, the application cant locate the access database even though i kept the db in the same directory of the application. Crystal report still remember the original location of the db. Looking for the help, please
Kind regards
Vinu
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 27 Jan 2009 at 1:32pm
You need to set the connection for the tables for the report prior to viewing the report.  That way it will look for the report in the current folder.  Using the ReportDocument object model and C#, the code looks something like this:
crReport = new ReportDocument();
crReport.Load(@rptPath + reportName);
CrystalDecisions.Shared.ConnectionInfo connectionInfo =
    new CrystalDecisions.Shared.ConnectionInfo();
connectionInfo.ServerName = <dbServer>;
connectionInfo.UserID = <user ID>
connectionInfo.Password = <password>;

Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
    TableLogOnInfo tableLogonInfo = table.LogOnInfo;
    tableLogonInfo.ConnectionInfo = connectionInfo;
    table.ApplyLogOnInfo(tableLogonInfo);
}

We use Oracle for our data, so the lines in red are for connecting to Oracle.  You'll need to check the documentation and change them as neede for your access database.  Also, if your report contains any subreports, you'll also have to walk through all of the objects in all of the sections in the report to see if the object is a subreport and then set the ConnectionInfo for each of the tables in the subreport as well.
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.031 seconds.