Sunday, November 29, 2009

Login failed for user sa crystal report


Login failed for user sa

In his “Troubleshooting Database Login Errors using Crystal Reports with .NET,” Eric Landes points out that he sees questions regarding the “Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed” message quite often in the newsgroups. That's an understatement. Since I use the “push” method (generating an ADO.NET dataset first, then setting the report's DataSource), I never saw this error, but I decided to try and replicate the problem to see why this was happening--it seems to be a popular error. I had a suspicion that impersonation and the “double hop“ (where the ASP.NET application cannot pass the user's credentials) may play a role in this problem, since the methods in Eric's article don't solve the problem for every user it should.

To replicate the problem, I used an ASP.NET project connecting to either a remote production SQL Server database or a copy of the same database on my development machine (SQL Server Developer Edition). I created a stored procedure that was just a simple SELECT statement, and used this stored procedure as my report source (“pull“ method). I probably created this report 20 different ways, testing various options, and here's what I found.


  1. Hi,
    I'm also using the same method that you are using to design the report.
    I just create a dummy stored procedure to just provide appropriate fields and then after report design I set in CrystalReportSource control the report file .rpt and set DataSources to SQLDataSource control and add required parameters and set their values by setting controls on Web form.

    The report is showing perfect on web page but when I click the Print button on report it shows this error sometimes it works and sometime not.

    Logon failed. Details: ADO Error Code: 0x Source: Microsoft SQL Native Client Description: Login failed for user 'sa'. SQL State: 28000 Native Error: Logon failed. Details: ADO Error Code: 0x Source: Microsoft SQL Native Client Description: Invalid connection string attribute SQL State: 01S00 Error in File C:\WINDOWS\TEMP\SalarySheet {BA60F633-E10B-4553-9EB8-0A50D8214CF9}.rpt: Unable to connect: incorrect log on parameters.

  2. If you are looking for better xml reporting software, please take a look at Windward's Xml Reports. With Windward you design reports in Microsoft Word, Excel, or PowerPoint so report design is a lot faster and easier - and non-programmers can design reports.