Click here to Skip to main content
15,917,615 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var report = new ReportDocument();
report.Load(Cr6Path);
                report.SetDatabaseLogon(repUser, repPass, repServer, repData, false);
                report.SetParameterValue("Stu_Id", Cr6StuId);
                report.SetParameterValue("Name", Cr6StuName);
                report.SetParameterValue("Level", Cr6StudentLevel);
                CrystalReportsViewer1.ViewerCore.ReportSource = report;
C#



What I have tried:

var report = new ReportDocument();
report.Load(Cr6Path);
                report.SetDatabaseLogon("sa", "*******", "VM-01", "DB_School", false);
                report.SetParameterValue("Stu_Id", Cr6StuId);
                report.SetParameterValue("Name", Cr6StuName);
                report.SetParameterValue("Level", Cr6StudentLevel);
                CrystalReportsViewer1.ViewerCore.ReportSource = report;
Posted
Updated 7-Jan-20 17:09pm

1 solution

If your report has multiple databases defined, you must change the logon info for all those databases. Also if you need to change the database or server, this method is not applicable. From ReportDocument.SetDatabaseLogon Method (String,String,String,String) (CrystalDecisions.CrystalReports.Engine) | Microsoft Docs[^]
Quote:
Logon information is applied only to tables with the same server name and database name. This method cannot be used to change the name of the database, or the server, that was originally specified in the report.

If this is the case, you can use Table.ApplyLogOnInfo Method (CrystalDecisions.CrystalReports.Engine) | Microsoft Docs[^]
 
Share this answer
 
Comments
Rabee3-F1.787545 8-Jan-20 4:07am    
Thanks for your reply but this report for one database
Wendelius 8-Jan-20 11:03am    
What about the other restriction, do you try to change the database or the server from the original?
tninis 8-Jan-20 5:29am    
Hello, you are using crystal report on WebForms ?

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