Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Good evening!


I am using CrystalReport XI for reporting and Visual studio 2008 .

I make one report with Sql server 2008 with server name suppose 'ABC' and DataBase Name 'DEF' everything good when i run my report with my computer database at which this report developed.

But when i deploy this report to other computer or server which Sql server 2008 server Name is 'XYZ' and database name is 'MNO' then this report prompt database login for only 'ABC'. If i update the old database to new database of this report then its work.
So every time i have to update the report Database server when i deploy the report to other machine.

I need any solution that i can pass the connection information by coding when i pass the parameter to this report.
I don't want to update the database every deployment.

So please help me.
Thanks
Posted
Updated 21-Dec-10 1:57am
v2
Comments
TweakBird 21-Dec-10 7:58am    
Improved Spellings.

Hi,
Set connection info
private void button1_Click(object sender, EventArgs e)
        {
            ReportDocument cryRpt = new ReportDocument();
            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables ;

            cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");

            crConnectionInfo.ServerName = "YOUR SERVER NAME";
            crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
            crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
            crConnectionInfo.Password = "YOUR DATABASE PASSWORD";

            CrTables = cryRpt.Database.Tables ;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }

            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh(); 
        }
 
Share this answer
 
v2
Comments
Toniyo Jackson 21-Dec-10 8:36am    
Use pre tag for code.
Use SetDatabaseLogon method of ReportDocument object.

Have a look at this one.

Crystal reports in ASP.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900