Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Parameters: setting datasource at runtime prompts login

Status
Not open for further replies.

huckfinn19

Programmer
May 16, 2003
90
CA
Hi, I am writing an application in C#2.0 with Crystal Reports XI Release 2. I am using a report viewer to display reports that need to connect to a distant DB. I need to set the datasource of my report programmatically so that my users don't have to know where the DB is or what credentials they need.

When I am not using Dynamic Parameters, tt works fine for the report to connect to the distant DB and download the data. I execute the report, no login prompt is displayed, data is downloaded and I am happy. The problems started when I added a dynamic parameter to my report. The parameter fills in a list from a view in the same distant DB where the report data is located. Using the code below, I set the TableLogOnInfo of the Report view to the EXACT same location as the Dynamic Parameter view and then when I execute the report, I get a Login prompt for the database! I then have to enter my DB credentials to be able to see Crystal's parameter prompt with the populated dynamic parameter.

How can I make sure that NO login prompt is displayed to the user for ANY connection to the database from my report for report data OR dynamic parameters?

Thanks in advance!

Below is the code I use to set the TableLogOnInfo:

Code:
oInfo.ServerName = oSettings.ToString("RptAddr");
oInfo.DatabaseName = oSettings.ToString("RptDatabase");
oInfo.UserID = oSettings.ToString("RptUsername");
oInfo.Password = oSettings.ToString("RptPassword");
Tables oTables = oReportDocument.Database.Tables;
foreach (Table oTable in oTables) {
	TableLogOnInfo oLogOnInfo = oTable.LogOnInfo;
	oLogOnInfo.ConnectionInfo = oInfo;
	// This appears to actually test the connection and will throw an exception if Logon failed.
	oTable.ApplyLogOnInfo(oLogOnInfo);
	// drop fully qualified table location 
	int nLastDot = oTable.Location.LastIndexOf(".");
	if (nLastDot > 0) {
		oTable.Location = oTable.Location.Substring(nLastDot + 1);
	}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top