views:

300

answers:

2

Hello,

After spending a good 3 to 4 hours on google trying to find any solution to my problem I haven't had much luck.

Basically, we use crystal reports for our .NET applications with a sql server back end, we have many clients each with their own server and so our reports need to have their connections dynamically set. Up until a week ago this worked fine. However a few days ago a client reported they were getting a database login prompt for a report (only one report, the rest worked fine). We were quite stumped but we managed to reproduce it on a netbook which didn't have visual studio or sql server installed. In the end the dev decided to reproduce the report in the hope it was just an oddity in that particular report.

Unfortunately a new client today also experienced the same problem, but this time for every crystal report they had - and also they worked on the netbook, so we are really quite lost here.

Below is a screenshot of what our clients get presented with -

Screenshot

and here is the code that I use to set the connection information in the report

                cI.ServerName = (string)builder["Data Source"];
                cI.DatabaseName = (string)builder["Initial Catalog"];
                cI.UserID = (string)builder["User ID"];
                cI.Password = (string)builder["Password"];

                foreach (IConnectionInfo info in cryRpt.DataSourceConnections)
                {
                    info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                }

                foreach (ReportDocument sub in cryRpt.Subreports)
                {
                    foreach (IConnectionInfo info in sub.DataSourceConnections)
                    {
                        info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                    }
                }

As always, any help much appreciated.

A: 

Perhaps the issue is the way that you set the authentication information. Have you considered using the ReportDocument.SetDatabaseLogon method? Call it once for each unique DB connection in the report. It will eliminate the need to enumerate all of the tables in the report and, as I recall, the need to enumerate the subreports' tables as well.

Craig
I have tried your suggestion but I still get the same error with the test - however, now it has got a database name in the logon prompt. Still fails though if I try entering the correct password.
Marlon
Does the dataase field get set?If you supply the proper logon credentials when the report prompts you, does the report work as expected?
Craig
If you hard-code the values into the SetDatabaseLogon, like reportDocument.SetDatabaseLogon("account","password","database","server"), does it work? To ensure that the subreport's logon information is being set, add this bit to your subreport loop as well. Let me know how it works and we'll try the next test.
Craig
The same process works absolutely fine on other clients environments - so I suspect its something to do with drivers / the way they have SQL server set up. But other than that I'm stumped. If I enter the correct details in the prompt I get a failed to connect message.
Marlon
A: 

Solution found, it turned out the connection builder that client used to set up their system did not put the instance name in. Rather confusingly the .net app worked fine with it like that. However, with that sorted crystal reports now work flawlessly.

Thank you for your input Craig.

Marlon