Print Page | Close Window

Setting LogonInfo to crystal report viewer

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4225
Printed Date: 28 Apr 2024 at 1:01pm


Topic: Setting LogonInfo to crystal report viewer
Posted By: Sunhere
Subject: Setting LogonInfo to crystal report viewer
Date Posted: 11 Sep 2008 at 12:50pm
Hello All,
I have a problem setting up the Logon info to the crystal report viewer.
Here is my code.

objects = infoStore.Query("Select SI_ID from ci_infoobjects where SI_NAME='" + objectName + "' and SI_PARENT_FOLDER=" + parentID.ToString() + " and SI_Instance=0");

if (objects.Count != 1) return (-1);

// GLTxnReportViewer is the crystalreportviewer control
this.GLTxnReportViewer.ReportSource = objects[1].ID;

this.GLTxnReportViewer.EnterpriseLogon = reportObject.BOEnterpriseSession;

// this code is for getting the report datasource, user id and pwd..
TableLogOnInfos oTblLogOnInfos = new TableLogOnInfos();

TableLogOnInfo oTblLogOnInfo = new TableLogOnInfo();

ConnectionInfo oConInfo = new ConnectionInfo();

oConInfo.ServerName = ConfigurationManager.AppSettings[sReportDataSource];

oConInfo.UserID = ConfigurationManager.AppSettings[sReportUserId ];

oConInfo.Password = ConfigurationManager.AppSettings[sReportPwd ];

oTblLogOnInfo.ConnectionInfo = oConInfo;

oTblLogOnInfos.Add(oTblLogOnInfo);

// end of the login code..

this.GLTxnReportViewer.LogOnInfo = oTblLogOnInfos;
 
So as shown in the above code, i will be getting the d/b datasource, userid and pwd from the config file, construct the tableloginInfos and set it to the crystal report viewer logoninfo.
My ultimate purpose is, i should be able to change the logon info dynamically when i change it in config file. i should not go to the cmc and modify the d/b parameters for that report.
 
The report works when the d/b info which i used while publishing the report matches with the config d/b info. If the d/b info differs, then it is throwing the logon screen for the report. Which i dont want.
 
So, I am thinking the setting the logon info to the viewer is not working..
I have gone thru the forums, where they will instantiate the report document object, loop thru the tables and set the logon for each of them. but in my case, i dont load the report, but i get the infoobject from the query....Dead
 
 



Print Page | Close Window