views:

8

answers:

0

I am using Crystal reports for Visual Studio 2010 beta 2. After upgrading my project from using Crystal reports 12.1 to 2010, it started showing up set Connection dialog. I am using oledb connection for reports while designing, the following code was working with Crystal 2008. I am using Visual Studio 2010 with Target Framework as 2.0

Any help is appreciated..

private bool SetReportConnections(ReportDocument oReport, string server, string db)
        {            
            if (!oReport.IsSubreport)
            {
                foreach (ParameterField pf in oReport.ParameterFields)
                {
                    pf.CurrentValues.Clear();
                }
            }
            //oReport.ParameterFields.Clear();
            foreach (CrystalDecisions.Shared.IConnectionInfo cInfo in oReport.DataSourceConnections)
            {
                cInfo.SetConnection(server, db, true);
            }

            foreach (Table table in oReport.Database.Tables)
            {
                table.LogOnInfo.ConnectionInfo.DatabaseName = db;
                table.LogOnInfo.ConnectionInfo.ServerName = server;
                table.LogOnInfo.ConnectionInfo.IntegratedSecurity = true;
                //table.Location = table.Location;
            }


            if(!oReport.IsSubreport)
            foreach(ReportDocument subReport in oReport.Subreports)
            {
                if(!SetReportConnections(subReport,server, db)) return false;
            }

            return true;
        }