cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Parameter Logon Prompt with .NET SDK

Former Member
0 Kudos

I'm at a loss as to how to solve this problem with a .NET solution that employs a SQL Command as the Crystal Report data source and has a dynamic parameter. The CrystalReports.Engine.ReportDocument is manipulated using C# code, providing the LogonProperties for each of the tables/commands in the report. However, it appears that it is not possible to set the ReportDocument.DataSourceConnections.LogonProperties at runtime.

I have tried the following code to achieve this:


foreach (InternalConnectionInfo internalConnectionInfo in Report.DataSourceConnections)

{

internalConnectionInfo.SetConnection("Server", "DBName", UserId, Password);

internalConnectionInfo.SetLogon(UserId, Password);

internalConnectionInfo.LogonProperties.Add(new NameValuePair2("UserID", UserId));

internalConnectionInfo.LogonProperties.Add(new NameValuePair2("Password", Password));

internalConnectionInfo.LogonProperties.Set("UserID", UserId);

internalConnectionInfo.LogonProperties.Set("Password", Password);

}

When I inspect Report.DataSourceConnections.Password value after running this code the Password is empty string(""). As implied by the object name it appears to be an INTERNAL object and although all these methods above are effective when inspecting the internalConnectionInfo object, these aren't set in the "parent" object, as mentioned.

1) Is it possible to set the Report.DataSourceConnections.Password value by code?


2) Where/how in code, can I pass the dynamic parameter the logon properties it needs so the user doesn't get prompted for them at runtime in a C# solution?


David Paynter

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi David,

Need to know what SDK package you are using?

CR will never show you the password and it is not saved in the RPT file.

Don

Former Member
0 Kudos

Hi Don

We currently have SAP Crystal Reports Runtime for .NET Framework V13.0.13.1597 and referencing the Crystal Reports .NET SDK in a Visual Studio 2013 environment on a Windows 8.1 platform.

I have gone through the whole Developer Guide and tried all the relevant techniques for setting the logon credentials including answering my own query above:

1) Set CrystalDecisions.CrystalReports.Engine.ReportDocument.DataSourceConnections.Password by executing the following code:

     DataSourceConnections dataSourceConnections = Report.DataSourceConnections;

     IConnectionInfo connectInfo = dataSourceConnections[0];

     connectInfo.SetConnection("Server", "DBName", "UserId", "Password");

Having done this, we can inspect the report object's properties and verify that all the logon data is held by the object. However, this logon data is not utilized by the ReportEngine, when accessing the database to populate the Dynamic Parameter with values from the database.

So we see a dialogue come up in the Windows Report Viewer titled "Enter Parameter Values" then the parameter name (ProductClass) and Server Name, User Name, Password, Use Single SignonKey. Completing the User Name and Password fields and clicking OK, proceeds to present the proper parameter UI and the report runs normally thereafter.

So the question remains:

2) Where/how in code, can I pass the dynamic parameter the logon properties it needs so the user doesn't get prompted for them at runtime in a C# solution?


Trust that clarifies the problem.


David

0 Kudos

Hi David,

I'm in the process of updating/writing a parameter test app so here's the initial flavor of it.

Be aware no all of this may work so you MUST run in debug mode to see what is going on. Some parts may not be complete. But it should help you debug this.

Try setting log on info first, UI you can enter the DSN or Server IP name, user, PW and Database and then on the right side you can use the dropdown to get the parameters.

Get the parameters before you try logging on to see what message you get.

Also, requires SP 14.

Don

Save the file and then unzip it. The output file has a .txt extension so remove the .txt extension and then unzip it again.

Former Member
0 Kudos

Hi Don

Many thanks for the very useful app. I utilized it to found that my report was not having the same issue in your app as in our solution. After porting across your methods directly into our solution, the problem still persisted. In depth analysis of code that ran after this led me to find the issue:

     the SQL Command "table" was having its location redirected to "DatabaseName.dbo.Command_1", whereas the Command is issued directly to the database connection without changing the location to what looks like an internal DB object.

The logon UI for the dynamic parameter was acting as a red herring with me thinking that it was related to this aspect of the report. However, your app made it possible for me to eliminate the logon code as the point of failure and focus on other code.

Thanks again.

David

0 Kudos

Great it helped....

Answers (0)