Database logon failed in Crystal Reports when using .NET disconnected Datasource

961 views Asked by At

I had a created an simple report using a disconnected dataset (employee). I then fill the dataset via code and pass it to the report using setdatasource.

The report displays correctly.but when i click on ZOOM, PRINT,EXPORT options the "Database Logon failed" appears

Using Visual Studio 2013, Dot Net framework 4.0, C# , SAP Crystal Reports 13.0.9

            SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
            con.Open();


            SqlCommand Cmd = new SqlCommand("Select * from Employees", con);
            SqlDataAdapter Da = new SqlDataAdapter(Cmd);

            DataSet dsEmp = new DataSet();
            Da.Fill(dsEmp);



            Employee dsEmployee = new Employee();
            foreach (DataRow dr in dsEmp.Tables[0].Rows)
            {
                DataRow drNew = dsEmployee.Tables[0].Rows.Add();

                drNew["FirstName"] = dr["FirstName"];
                drNew["LastName"] = dr["LastName"];
                drNew["Name"] = dr["FirstName"].ToString().Trim() + " " + dr["LastName"].ToString().Trim();

            };



            //ReportDocument myReport = new ReportDocument();
            //myReport.Load(Server.MapPath("~")+ "\\CrystalReportDataset.rpt");
            //myReport.SetDataSource(emp);
            //myReport.Database.Tables["dtEmp"].SetDataSource(emp.Tables[0]);
            //myReport.VerifyDatabase();
            //CrystalReportViewer1.ReportSource = myReport;
            //CrystalReportViewer1.EnableDatabaseLogonPrompt = false;


            CrystalReportDataset MyRpt = new CrystalReportDataset();
            MyRpt.SetDataSource(dsEmployee);
            MyRpt.Database.Tables[0].SetDataSource(dsEmployee.Tables[0]);
            CrystalReportViewer1.ReportSource = MyRpt;
0

There are 0 answers