Last post Aug 11, 2011 11:24 AM by shirowkhan
Aug 10, 2011 03:14 PM|shirowkhan|LINK
Been trying all day to get this report done programmatically, it will work once i dynamically create it but when i try to code it it gives me the error, "No valid report source is available".
This is my code
protected void cmdShorReport_Click(object sender, EventArgs e)
ReportDocument Report = new ReportDocument();
crvReports.ReportSource = Report;
I downloaded the latest version of sap crystal reports for vs2010. For the life of me i cant get this thing working programmatically.
Aug 11, 2011 12:55 AM|necro_mancer|LINK
please have a look at
Aug 11, 2011 10:48 AM|shirowkhan|LINK
I'm sorry, that doesnt help due to the fact that i'm using vs2010. I cant even define a new instance of the CrystalReportSource in code behind. I just cant understand why it would allow me to load the report source when all the examples i have gone t hrough
say they same thing. I just seem to find out what it is i'm doing wrong. I t ried this method and it didnt work either. (This is done below a button click method)
CrystalDecisions.Web.Report Report = new CrystalDecisions.Web.Report();
Report.FileName = "Report.rpt";
crsReports.Report = Report; //This crystalreportsource is an object on the design page
crvReports.ReportSource = crsReports;
That doesnt work either. I knwo the report loads because i've tested for it. However i jsut cant figure out why its not a valid source. Does anyone have a working report in vs2010 and if so can i see your code please.
Aug 11, 2011 11:24 AM|shirowkhan|LINK
Interesting thing happened. When i put the login info for the server into code, then i'm able to generate the report programmatically, if i remove it, i get back the "No valid report source" error.
I'm guess the connection info to the server/db is required to complete the report as the darn thing wont show at all. I placed the code in a function as shown below. For anyone who has this problem include the login parameters below.
private void reportLogin()
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables ;
cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
crystalReportViewer1.ReportSource = cryRpt;