Click to See Complete Forum and Search --> : [RESOLVED] crystal reports on webpage


dannystommen
June 11th, 2009, 07:08 AM
A while ago, I succesfully create a crystal report (in a Windows app.)

Now I want to show this same report in a webpage.

My approach
-> Retrieve data from database using the SqlConnection class
-> Fill a dataset with the information from the database
-> create a new DocumentReport, fill this with the dataset
-> set the documentReport to the reportSource of the reportviewer

In the win.app. this works fine, but in my webpage, I get promted for login details

The report you requested requires further information.

servername: dsSiteList
database name:
username:
password:
[checkbox] use integrated security


the servername 'dsSiteList' is the name of the Dataset. Sincse when does a dataset requires login information?

Contacting the sqlserver works fine.

I searched the web for few hours now, with al lot of possible solutions, but none of them worked.

eclipsed4utoo
June 11th, 2009, 09:01 AM
if possible, I would not use Crystal Reports in a webpage.

I just spent the past 2 days wrestling with getting a report designed in Crystal Reports XI to work in a VS2008 web site. Per Business Objects, CR XI R2 was never QA'ed to work with VS2008. My report was way too complicated to be designed in another application(Microsoft Report or SQL Server Reporting Services), so I had to make it work. I did finally get it to work, but it's hacked together.

here is the code we use. We don't use a dataset, we set the report up with parameters, and we populate those parameters.

Crystal Database Login

public void CrystalLogin(CrystalDecisions.CrystalReports.Engine.ReportDocument rptReportDocument,
string pCRDatabaseUserName_Str, string pCRDatabasePassword_Str, string pCRServerName_Str, string pCRDatabaseName_Str)
{

CrystalDecisions.CrystalReports.Engine.Database dbCR = rptReportDocument.Database;
CrystalDecisions.CrystalReports.Engine.Tables tblsCR = dbCR.Tables;
CrystalDecisions.Shared.TableLogOnInfo tliCRTableLogonInfo;
CrystalDecisions.Shared.ConnectionInfo conninfoCR = new CrystalDecisions.Shared.ConnectionInfo();
conninfoCR.DatabaseName = pCRDatabaseName_Str;
conninfoCR.ServerName = pCRServerName_Str;
conninfoCR.UserID = pCRDatabaseUserName_Str;
conninfoCR.Password = pCRDatabasePassword_Str;


foreach (CrystalDecisions.CrystalReports.Engine.Table tblCR in tblsCR)
{
tliCRTableLogonInfo = tblCR.LogOnInfo;
tliCRTableLogonInfo.ConnectionInfo = conninfoCR;
tblCR.ApplyLogOnInfo(tliCRTableLogonInfo);
tblCR.Location = conninfoCR.DatabaseName + ".dbo." + tblCR.Location.Substring(tblCR.Location.LastIndexOf(".") + 1);
}

for (int counter = 0; counter < rptReportDocument.Subreports.Count; counter++)
{
CrystalDecisions.CrystalReports.Engine.Database dbCR2 = rptReportDocument.Subreports[counter].Database;
CrystalDecisions.CrystalReports.Engine.Tables tblsCR2 = dbCR2.Tables;
CrystalDecisions.Shared.TableLogOnInfo tliCRTableLogonInfo2;
CrystalDecisions.Shared.ConnectionInfo conninfoCR2 = new CrystalDecisions.Shared.ConnectionInfo();
conninfoCR2.DatabaseName = pCRDatabaseName_Str;
conninfoCR2.ServerName = pCRServerName_Str;
conninfoCR2.UserID = pCRDatabaseUserName_Str;
conninfoCR2.Password = pCRDatabasePassword_Str;
foreach (CrystalDecisions.CrystalReports.Engine.Table tblCR2 in tblsCR2)
{
tliCRTableLogonInfo2 = tblCR2.LogOnInfo;
tliCRTableLogonInfo2.ConnectionInfo = conninfoCR2;
tblCR2.ApplyLogOnInfo(tliCRTableLogonInfo2);
tblCR2.Location = conninfoCR2.DatabaseName + ".dbo." + tblCR2.Location.Substring(tblCR2.Location.LastIndexOf(".") + 1);
}
}
rptReportDocument.VerifyDatabase();
}


Setting Parameters

public void SetReportParameters(ReportDocument rd, string ItemNumber)
{
rd.SetParameterValue("@ItemNumber", ItemNumber);

foreach (ReportDocument r in rd.Subreports)
{
rd.SetParameterValue("@ItemNumber", ItemNumber, r.Name);
}
}



main code

ReportDocument rpt = new ReportDocument();
rpt.Load(@"C:\test.rpt");

CrystalLogin(rpt, DBUser, DBPassword, Server, DBName);
SetReportParameters(rpt, "12345");

reportViewer1.ReportSource = rpt;


This uses the CrystalReportViewer to display on the form.

dannystommen
June 12th, 2009, 06:20 AM
Thanks for your reply.

The code works fine, but the problem is, my report is too complex to retrieve the data directly out the database. So I need to use a dataset.


The strange thing is, when I had that message, I copied/pasted the report from one directory to another.
After it, I started again, and added it as an existing item. I don't know what I did different, but it suddenly worked.

I created this page in a folder named 'reports'. After publishing it, I got an error Service Unavailable. Apperently it is not allowed to have a 'reports' folder in IIS. Thus, I created an new folder named 'reporting', and now I am facing the same problem again :(

I even created the dataset's from scratch, but still gives me the same problem.

dannystommen
June 12th, 2009, 11:35 AM
I found the problem.

I have option that the user can check if they want to include images or not. If they choose not to, the datatable was not filled. Now I fill the datatable with images of 1x1 pixel and everything works fine.

Thanks for help anyway