Quantcast
Channel: Crystal Reports
Viewing all articles
Browse latest Browse all 1507

Database logon failed when opening report with parameter values in CrystalReportViewer

$
0
0

Hi,

I designed 2 crystal reports: report A contains parameter fields and report B did not contain any parameter

I can open both reports in development site using CrystalReportViewer control. When I open the reports intesting site, I can open report B but can't open report A. It display error message "Database logon failed". When I set EnableDatabaseLogonPrompt to true and try to open the report A again, it shows database connection data which was created on report.

In addition, it is strange that it displays error "Database logon failed" when I click an item in group tree panel of the report B. This indicates that it can load data from database
in testing site but it connect to development database when clicking items in group tree panel

All reports connect to database using Windows Authenication. It use dynamic database connection at runtime

How to ensure the report always connect database using login data dynamically at runtime?

Below is my code about database connection:

---------------------------------------------------------------------

string strServerName = null;
string strDatabaseName = null;

ReportDocument rptDoc = new ReportDocument();

rptDoc.Load(strFilePath);

ConnectionInfo connInfo = new ConnectionInfo();
TableLogOnInfo logonInfo;

for (int i = 0; i < rptDoc.Database.Tables.Count; i++)
{
logonInfo = rptDoc.Database.Tables[i].LogOnInfo;

ReportHelper.GetReportConnection(ref strServerName, ref strDatabaseName, strSystemType);

logonInfo.ConnectionInfo.ServerName = strServerName; 
logonInfo.ConnectionInfo.DatabaseName = strDatabaseName;

logonInfo.ConnectionInfo.IntegratedSecurity = true;
rptDoc.Database.Tables[i].ApplyLogOnInfo(logonInfo);
rptDoc.Database.Tables[i].Location = rptDoc.Database.Tables[i].Location.Substring(0, rptDoc.Database.Tables[i].Location.Length - 2);
}

crvViewer.ReportSource = rptDoc;

crvViewer.DataBind();

--------------------------------------------------------------

Development environment:

- SAP Crystal Reports 2013 Support Pack 1
- Visual Studio Professional 2012
- .NET Framework 3.5
- DDL
CrystalDecisions.Shared (v 13.0.8.1216)
CrystalDecisions.Web (v 13.0.8.1216)
CrystalDecisions.CrystalReports.Engine (v 13.0.8.1216)

Database connection in crystal report:

- Database Type: OLEDB (ADO)
- Provider: SQLOLEDB
- Integrated Security: True

Thanks and Regards,
Tony


Viewing all articles
Browse latest Browse all 1507

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>