cancel
Showing results for 
Search instead for 
Did you mean: 

Report prompts for database login, although no database connection is set

Former Member
0 Kudos

Hey,

I'm using Visual Studio 2010, as well as Crystal Reports for .NET Framework (v13.0.12.1494).

I'm working on a tool, which collects data from a database and provides a list of objects to a report, to display this data. On my developer machine everything is working as expected, but when I want to run the tool on a test PC, a prompt pops up to enter database login credentials, once the report is opened. Since there is no database for the report to connect to, this prompt does not make any sense. The test PC has the runtime SP 12 installed.

This is where the report is created (the code-behind of a WPF window):


        private readonly List<MeasureTestResult> m_MeasurementList;

        private readonly MeasureLog m_ResultLog;

        private void Window_Loaded(object sender, RoutedEventArgs e)

        {

            ReportDocument report = new ReportDocument();

            report.Load("Sources/Report/ExportReport.rpt");

                       

            report.SetDataSource(m_MeasurementList);

           

            // wrap the result log object in an array, otherwise an error is thrown

            report.Subreports[0].SetDataSource(new[] { m_ResultLog });

            CrystalReportsViewer1.Owner = GetWindow(this);

            CrystalReportsViewer1.ViewerCore.ReportSource = report;

            CrystalReportsViewer1.ViewerCore.ToggleSidePanel = Constants.SidePanelKind.None;

        }

What can I do to get this to work?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Martin

Please see the following on how to troubleshoot issue the issue:

Troubleshooting Issues with VS .NET Datasets and Crystal Reports - Business Intelligence (BusinessOb...

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hey Ludek,

thanks for your answer. I followed the steps of the wiki, but unfortunately, it didn't help.

To get the steps in the wiki to work I filled a DataSet with the data from the objects that I originally provided and set this DataSet as the source for the report. The content of the generated XML files looks fine and when I set the datasource location there are also no Map Fields dialog. Everythings seems to be fine, but I still get the login prompt on the test PC. The login is for the database "NewDataSet", by the way. I thought that CR would recognize that I'm only trying to display a dataset and thus not prompt for the login, but it seems I was wrong.

former_member183750
Active Contributor
0 Kudos

Hi Martin

Your assumption re. "I thought that CR would recognize that I'm only trying to display a dataset and thus not prompt for the login..." is correct. But a bit of an explanation; when you point the report at the dataset, the report engine will require that the dataset matches precisely what it is expecting as per when the report was designed. Failing that, the report will try to bypass the dataset and connect to the database. And that is the last thing it does - fails and thus the logon error.

E.g.; the report engine is seeing that the dataset is different than what it is expecting.

So, to proceed, take the exported from xml from the 1st test (that you used in the designer). Create a new test app. In the app, use the xml and stuff that into a dataset. Point the report at the dataset. Does that work?

- Ludek

Former Member
0 Kudos

I created a test app and also created a new quick-and-dirty report for this app, which used the created xml files as data sources.

When I tested this on the test PC, it did indeed work. I then replaced the new report with the actual one (which should use the same data source, so this should work), but when I tested that on the test PC, the prompt came up again.

So it seemed that the original report did indeed seem to have a problem. I re-checked the schema definition and found one data type discrepancy, which oddly enough didn't come up earlier, when I followed the steps of the wiki. I also redid the subreport-part, because it seemed it was still having some old data source references.

When I used this edited report in the test app, it was actually working! I then tested it in my original report tool and it was also working there.

So long story short: it's working now and thanks for your help

Former Member
0 Kudos

One follow-up question though: why is it, that the report accepts everything on the development PC and displays the data, but not on the test PC?

The fact that there is a difference makes the development of the reports kind of tricky, because you can never be sure, that eveything is working for everyone, just because it works on your own PC.

former_member183750
Active Contributor
0 Kudos

Hi Martin

Great questions - kind of a mystery wrapped in an enigma . E.g.; here I go blowing hot air and hoping...

The data type difference should have been caught by the first test you did. First time I hear of this not happening...

Re. difference between Dev and test PC. Double check the datasets on both - are they really identical?

Is the CR runtime identical between the two PCs? Perhaps the VC++ runtime is different leading to different behavior?

I do understand your concerns re. the different behaviors, but honestly, up to now, these sorts of issue have all been related to diffs in datasets.

- Ludek

Message was edited by: Ludek Uher

Former Member
0 Kudos

Hi,

I experienced similar problem using CR for VS2013. On some machine the reports were running OK, and on other the report asked for login information but never actually connected.

I used the following code to modify the login information from vb.net:

report refers to ReportDocument using: report.Load(reportPath)


    Private Sub SetReportDatabseConnection()

        'Set Database Connection...

        Dim crConnectionInfo As New ConnectionInfo()

        With crConnectionInfo

            .ServerName = My.Settings.ServerName.ToString

            .DatabaseName = "NimaDB"

            .IntegratedSecurity = My.Settings.IntegratedSecurity

            If Not .IntegratedSecurity Then

                .UserID = My.Settings.user.ToString

                .Password = My.Settings.pass.ToString

            End If

            .Type = ConnectionInfoType.SQL

        End With

        For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In report.Database.Tables

            Dim crTableDBinfo = crTable.LogOnInfo

            crTableDBinfo.ConnectionInfo = crConnectionInfo

            crTable.ApplyLogOnInfo(crTableDBinfo)

            If report.ParameterFields.Count = 0 Then

            End If

        Next

    End Sub

But I still receive the (failing) login prompt on some machine

It took me few days until I actually found the problem:

The SQL Client (SqlCLIn) driver was missing from the client machine.

After I installed the appropriate client (make sure you use the version that match your server), all are working great.

--

former_member183750
Active Contributor
0 Kudos

Beautiful. Many thanks for sharing Ron!

Answers (0)