[RESOLVED] How to get rid of the login box
Hello everybody,
I am using CR 10 with ASP.NET 1.1/MSSQL. Whenever I run the report from application, it first shows a page where it asks SQL Server username/password and then it shows the report. My report is directly connected to a View in the SQL Server database.
How can I get rid of this login box when the report is presented from the application?
Thanks.
Re: How to get rid of the login box
see my post http://www.vbforums.com/showthread.php?t=451212, you need to apply logon information to each table of the report.
Re: How to get rid of the login box
Thanks a lot. I will try your code and will let you know.
Re: How to get rid of the login box
I converted your code in C# and tried but getting logon failed exception. Here's the code.
Code:
Database crDatabase;
Tables crTables;
//CrystalDecisions.CrystalReports.Engine.Table crTable = new CrystalDecisions.CrystalReports.Engine.Table();
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo;
ReportDocument crReportDocument = new ReportDocument();
crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "LOCALHOST";
crConnectionInfo.DatabaseName = "PCSNSurvey";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "sa";
crReportDocument.FileName = Server.MapPath("Reports/CustomerList.rpt");
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
rptCustomerList.ReportSource = crReportDocument;
I am getting exception on the following line, however I am providing simple login credentials of my local pc.
crTable.ApplyLogOnInfo(crTableLogOnInfo);
Would you please help me out with this?
Thanks.
Re: How to get rid of the login box
I am trying this code as well. It doesn't throw exception when report is loaded but shows report with old data. When I click Refresh, application blows up and says "Login failed.".
Code:
CrystalDecisions.CrystalReports.Engine.ReportDocument reportDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
reportDoc.FileName = Server.MapPath("Reports/CustomerList.rpt");
string serverName = PCSN.SurveyApplication.BusinessLogicLayer.DatabaseInfo.GetServerName();
string databaseName = PCSN.SurveyApplication.BusinessLogicLayer.DatabaseInfo.GetDatabaseName();
string userName = PCSN.SurveyApplication.BusinessLogicLayer.DatabaseInfo.GetUserName();
string password = PCSN.SurveyApplication.BusinessLogicLayer.DatabaseInfo.GetPassword();
reportDoc.SetDatabaseLogon(userName,password,serverName,databaseName,true);
rptCustomerList.ReportSource = reportDoc;
Thanks.
Re: How to get rid of the login box
Basically login problem in the CR will occur when the report can not find the data table. I make a different code for this but it is VB.NET, Just read CR in VB.NET at my signature.
Re: How to get rid of the login box
The problem was on my side. Basically I need to provide login information and survey name for DSN.
Thanks.
Re: How to get rid of the login box
Quote:
Originally Posted by usamaalam
The problem was on my side. Basically I need to provide login information and survey name for DSN.
Thanks.
Ok that is other matter, no idea about that. :)
Re: [RESOLVED] How to get rid of the login box
Yes, basically reports were designed by some other developer and I didn't notice it is going to connect via DSN. Now I can use it from application without a login box.
Thanks.