Click here to Skip to main content
15,071,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to crystal report. I want to bind crystal report viewer to the datatable fetched from the database through store procedure by passing the parameter through text box. Bt m getting the error database logon failed , code behid coding is:



C#
oSubmitReportBLL.PostedOn = txtDate1.Text.Trim();
        DataTable  dt= new DataTable();
        dt = oSubmitReportBLL.SelectRecievedReports();

      
        ReportDocument r = new ReportDocument();
        string reportpath = Server.MapPath("~/CrystalReport.rpt");
        r.Load(reportpath);
        DataSet DataSet1 = new DataSet();
        DataSet1.Tables.Add(dt);
        r.SetDataSource(DataSet1);
        CrystalReportViewer1.ReportSource = r;


plaese help me out...
Posted
Updated 7-Nov-12 22:07pm
v2

1 solution

C#
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(@"C:\Documents and Settings\shawpnendu\My Documents\Visual Studio 2008\WebSites\Crystal Report 1\CrystalReport.rpt");
  crystalReport.SetDatabaseLogon("sa","password",@".\SQLEXPRESS","TestDB");
crystalReport.SetDataSource(oSet);
CrystalReportViewer1.ReportSource=crystalReport;




http://stackoverflow.com/questions/10169062/database-logon-failed-when-connecting-crystal-report-with-asp-net[^]


http://www.daniweb.com/web-development/aspnet/threads/235968/to-pass-login-information-in-asp.net-c-crystal-report[^]
   
v2
Comments
[no name] 8-Nov-12 4:08am
   
sir that problem is solved bt nw the error is coming that 'no valid report source is avilable'
vivektiwari97701 8-Nov-12 4:14am
   
can u provide ur code ...
crystalReport.SetDatabaseLogon("sa","password",@".\SQLEXPRESS","TestDB");
put this above line after
crystalReport.Load(..)
---------------------------
or try "Server.MapPath("CrystalReport.rpt");" instade of "Server.MapPath("~/CrystalReport.rpt");"
[no name] 8-Nov-12 4:28am
   
same error is ocurring.. sir
vivektiwari97701 8-Nov-12 4:38am
   
ok where u r writing ur cod i mean in witch event??????
vivektiwari97701 8-Nov-12 5:00am
   
ok try to follow this article
http://www.codeproject.com/Questions/276291/Crystal-Report-Viewer-Problem

and let me know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900