Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem changing Database server at runtime: ApplyLogOnInfo() not working

Hi all,

I am using CR2008 v12.0.0.683 with VS2008 v9.0.21022.8 RTM.

Crystal Reports 2008 for Visual Studio. Windows XP SP3.

I am developing a Web application that uses a PervasiveSQL v10.01 database.

I have used exactly the same code used in the sample provided for Visual Studio:


Unfortunately, right after the execution of table.ApplyLogOnInfo(tableLogOnInfo), the values of the TableLogOnInfo go back to the values stored on the original report, and worst of all, I got the error:

"Failed to open the connection"

The report I am currently using is a very simple one I have just created to simplify the problem. It lists just one table without any subreports or parameters. The table listed exists in both databases I want to test, the original set on the report and the one I want the report to collect the information from.

Any idea about why the method ApplyLogOnInfo is not working?

protected void Page_Load(object sender, EventArgs e)


string reportName = Request.QueryString\"reportName\";

string reportPath = ConfigurationManager.AppSettings.Get("CrystalReportsDefaultFolder") + reportName;

ReportDocument crDocument = new ReportDocument();


string dbuser = "dbuser";

string dbpass = "dbPass";

string dbserver = "dbserver";

string dbname = "dbname";

setConnectionDatabaseString(crDocument, dbserver, dbname, dbuser, dbpass);

crystalReportViewer.ReportSource = crDocument;


public void setConnectionDatabaseString(ReportDocument document, string server, string database, string user, string password)


ConnectionInfo connectionInfo = new ConnectionInfo();

connectionInfo.ServerName = server;

connectionInfo.DatabaseName = database;

connectionInfo.UserID = user;

connectionInfo.Password = password;

Tables tables = document.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)


TableLogOnInfo tableLogOnInfo = table.LogOnInfo;

tableLogOnInfo.ConnectionInfo = connectionInfo;



Many thanks in advance!

Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question