Click here to Skip to main content
15,896,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,
even though I found a lot of articles about Crystal reports and ASP.NET it seems that I can't make it work.
I'm trying to load a crystal report to a web form and I'm getting prompted the logon window even thought I added the connection info to the code as you can see below:
ConnectionInfo myConnectionInfo = new ConnectionInfo();

 myConnectionInfo.ServerName = "server";
 myConnectionInfo.DatabaseName = "DB1";
 myConnectionInfo.UserID = "user";
 myConnectionInfo.Password = "pass";

 ReportDocument cryRpt = new ReportDocument();

 cryRpt.Load(Server.MapPath("~/test.rpt"));

 TableLogOnInfos mytableloginfos = new TableLogOnInfos();
 mytableloginfos = CrystalReportViewer2.LogOnInfo;
 foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
   {
     myTableLogOnInfo.ConnectionInfo = myConnectionInfo;
   }

 CrystalReportViewer2.ReportSource = cryRpt;


Any ideas how to load a report without be asking for login info?

Thank you in advance.

What I have tried:

1. I added the following line but I get the error message "Database logon failed."

CrystalReportViewer2.EnableDatabaseLogonPrompt = false;


2. I added the connection info on CrystalReportViewer2_Init but the problem remains the same.
Posted
Updated 23-Jun-16 20:04pm
v3

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

  Print Answers RSS


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