问题
I have a crystal report designed using xsd file (dataset with ado.net connection). Crystal version 14.2.5.2618 and using vs 2017... deployed to .net 4.7.2 framework website. I have a service (WCF) returning a dataset that is valid and filled. When I deploy the report to the web server the report prompts for a database login even though it is fine in development. Here is the code with names changed to protect the innocent.
m_myRPT.Load(Server.MapPath("~/Reports/my.rpt"))
m_myRPT.PrintOptions.PaperOrientation = PaperOrientation.Portrait
m_myRPT.SetDataSource(m_DS.Tables("dtData")) 'returned from WCF and is fine
CRV_reportviewer.ReportSource = m_MyRPT
CRV_reportviewer.DataBind()
Like I said, this works fine in development. All data is returned properly and the dataset checks out too. My questions are:
1) Do I HAVE to use SetDatabaseLogon (WCF service supplies data... report should not have access to database and I don't want it to access either)
2) Can I set this up so the dataset table suffices for report data ...
3) Shouldn't the DataSet with a valid table full of data suffice for the report to display...
So basically...
4) How can I get rid of prompt (preferably without the report having access to the database) ?
Any answer to these questions would be great... I do not mind changing the report so it does not prompt for data without having to hard code database access credentials anywhere on the web pages... WCF Service provides data... n-tier application... I know these are four questions in one but number four is what I really need answered if anyone would be so kind
I used Crystal many times over the years but cannot recall having to give it access to the database...
Best Regards and thank you in advance;
回答1:
1, You must to ensure, that name of DataTable is the same in CrystalReport, if yes, go next step
2, It s not enough to only Set DataSource to a report, you must pass data to a report :
ds.WriteXml(XmlDataPath)
save your dataset as xml, now you can add your generated xml to a Crystal Report, so open Crystal Report, go to Database> Database expert> Create New Connection> ADO.NET(xml) and choose path to generated xml
I faced the same problem, and these steps helped me
来源:https://stackoverflow.com/questions/54428830/crystal-reports-asp-net-do-i-have-to-use-setdatabaselogon