How to resolve "Logon Failed" Error in crystal report

Hi friends,

Crystal report is a rich tool of reporting and analysis.when you setup in win application.it works good in development side.but when setup in deployment side come this logon fail error.

This error come because crystal report set database connection in report data.and when we change database location or change server then crystal report can't connect with database.so this error come to user.


for solution this problem need some code for resolve this issue.this call set login detail to crystal report.

//create ReportDocument
CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

//ConnectionInfo
ConnectionInfo info = new ConnectionInfo();

//set database server name
info.ServerName = Server name;

//set database userid
info.UserID = userid;

//set database password
info.Password = password;

//set database IntegratedSecurity
info.IntegratedSecurity = false;

//set report used database tables
foreach (CrystalDecisions.CrystalReports.Engine.Table Table in cryRpt.Database.Tables)
{
TableLogOnInfo TableLogOnInfo = Table.LogOnInfo;
TableLogOnInfo.ConnectionInfo = info;
Table.ApplyLogOnInfo(TableLogOnInfo);
}


This code set  report connection to database.and fatch data from database.this code help u to resolve login fail problem.

Comments

Popular posts from this blog

Populate combo box for month and year in c#

How to get month days count from date or month and year

CRUD Operations in win form application with access database