Crystal Report Logon Failed Problem

I am using....

Framework 3.5 C# Visual Studio 2008 and web based application

I have created reports using Dataset i.e. my service gives me data set and I bind that dataset with report.

But sometimes CR viewer started popping up error "Logon Failed" with login box with dataset name filled in login information.

I am searching for its solution for quite some time but did not fine any suitable answer to this.


This error is unfortunately ambiguous because it is the generated error for dozens of unrelated problems. In this case, the "Logon failed" is likely due to an occasional schema mismatch.

The DataSet object can contain hierarchical data. If your service is returning a DataSet containing hierarchical data, and some of the children are missing, then its schema has effectively changed.

There are several ways to ensure that the DataSet has a matching schema. If you are serializing objects into XML and then generating the DataSet from that XML, then a simple way to achieve a consistent schema is to change your code from:

reportData.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(reportXml)));


        new MemoryStream(Encoding.UTF8.GetBytes(reportXml)),

where schemaPath points to an XSD file that was generated earlier in development with a call to


When generating the schema, you will also want that schema to be as complete of a representation of the data as possible, so you will want to use as complete of a hierarchy of data as possible. This is also the XML that the report must be created off of so that its schema matches. If the schema changes, then the report must be opened in the designer with the new data and you must "verify database" and then save the RPT file.

Are you passing along your creditials in your code:

ReportDocument rep = new ReportDocument();
rep.FileName = Server.MapPath("CrystalReport1.rpt");
set.SetDatabaseLogon("username", "password", "sql-server", "database"); // this line pass the login parameters required for login

After long efforts i figured the main reason, there was a mistake in my stored procedure which was returning data.

SP returns data from table1 or table2 (they both have same structure), but when I was picking data from table2 i did not write all the column names which were required.

Seems quite weird , i should get something like column not found error instead of database logon failed.

Try this out. Also make sure you have right version of crystal report in all places

private ConnectionInfo crConnectionInfo = new ConnectionInfo();
        ReportDocument rpt = new ReportDocument();
        protected void Page_Load(object sender, EventArgs e)
            CrystalReportViewer1.Width = 900;
            CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None;

        private void BindReport()

            DataSet ds = getReportData();
            CrystalReportViewer1.ReportSource = rpt;

        private DataSet getReportData()
            DataSet ds = new DataSet();
            string ConnectionString = ConfigurationManager.ConnectionStrings["myconn"].ConnectionString;
            SqlConnection con = new SqlConnection(ConnectionString);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "GetProductList";
            cmd.CommandType = CommandType.StoredProcedure;            
            cmd.Connection = con;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            sda.Fill(ds, "ctable");
            return ds;

I was facing the same issue at the time, when I moved the application from the development machine to the real server. It was an IIS7 MVC application( CR 13.0) with trusted authentication to the SQL server.

The way I fixed it, was by creating a new application pool for the application. I give permission for the new application pool user IIS APPPOOL\applicationpoolname to the SQL server database that was used in the application. Then the error went away.

My assumption is that, the userlogininfo applied through code is not always used by the CR runtime , instead it uses the IIS user login info.

Need Your Help