I am trying to print crystal report in PDF format , and on my local machine it’s working fine. But when I publish application to the server, it’s giving me the following error on Print button . I am using VS2012 , SQl Server 2012, IIS 7.5 and CR version 13.5 Note: I am using integrated security so I left username and password blank. Please help. My lines of code:
string Constring1 = ConfigurationManager.ConnectionStrings["dbRMCConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(Constring1);
conn.Open();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("RMCChallan.rpt"));
ParameterFieldDefinitions crParameterFieldDefinations;
ParameterFieldDefinition crParameterFieldDefination;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterValues.Clear();
crParameterDiscreteValue.Value = lbl_Cno.Text;
crParameterFieldDefinations = rpt.DataDefinition.ParameterFields;
crParameterFieldDefination = crParameterFieldDefinations[0];
crParameterValues = crParameterFieldDefination.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefination.ApplyCurrentValues(crParameterValues);
rpt.SetDatabaseLogon("", "", "ADMIN-PC\\ADMIN", "dbRMC");
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, Guid.NewGuid().ToString());
Thanks for your help in advance !! :)
Stack Trace: I am trying to print crystal report in PDF format , and on my local machine it’s working fine. But when I publish application to the server, it’s giving me the following error on Print button . I am using VS2012 , SQl Server 2012, IIS 7.5 and CR version 13.5 Note: Using windows authentication..No username and password assigned to my database. Server Error in '/' Application.
Database logon failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Database logon failed.
Source Error:
Line 178: crParameterFieldDefination.ApplyCurrentValues(crParameterValues);
Line 179: rpt.SetDatabaseLogon("", "", "ADMIN-C\\ADMIN","MyDatabase");
Line 180: rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, Guid.NewGuid().ToString());
Line 181:
Line 182:
Source File: e:\25jan14\WebSite1\RMC.aspx.cs Line: 180
Stack Trace:
[COMException (0x8004100f): Database logon failed.]
CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) +0
CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +257
[LogOnException: Database logon failed.]
CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) +332
CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +310
CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) +654
CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options) +92
CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToHttpResponse(ExportOptions options, HttpResponse response, Boolean asAttachment, String attachmentName) +96
CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToHttpResponse(ExportFormatType formatType, HttpResponse response, Boolean asAttachment, String attachmentName) +119
RMC.Button5_Click(Object sender, EventArgs e) in e:\25jan14\WebSite1\RMC.aspx.cs:180
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553594
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
7条答案
按热度按时间xtupzzrd1#
We had the same issue. Ended up that we needed to install the Microsoft SQL Server 2012 Native Client (available at https://www.microsoft.com/en-us/download/details.aspx?id=29065 , click Install Instructions and scroll towards the middle).
We were able to tell this because Process Monitor was showing NOT FOUND errors accessing the HKCR/SNCL11 registry key.
drkbr07n2#
1.clear dataset connection.
2.set table or tables.
3.don't set datasource and dataset. becuase you sent data to crystal report.
4.refresh the reportdocument.
see this in bottom:
enyaitl33#
Are you sure you need two slashes?
Also, here is a link to msdn refrence for SetDatabaseLogon.
http://msdn.microsoft.com/en-us/library/ms226065(v=vs.80).aspx
The sample in the article is using standard security login account.
You are missing user and password in the call.
It is also like you are trying to perform a trusted connection. You could try using a local ODBC connection on the web server, but it might prompt the user for AD credentials.
Good luck
b09cbbtk4#
In case someone else also finds this question, here's what my problem was, and how I fixed it:
I had to edit some old reports in order to add a new table to them. As part of that process I had to create a new connection and change the table locations for the pre-existing tables. All worked well until trying to deploy to the production environment, where the table locations are dynamically changed in code.
So I Googled, found this question and realised that the answer by @Chet (+1) could be a clue. And it was - I had created the new connection as
Sql server native client ##
.However, instead of messing with the prod server, I remade the new connection using an
OLE DB (Sql server)
connection, and then it worked in all relevant places (dev, test, prod envs).ibrsph3r5#
i faced a similar problem recently, it worked when i changed the locale identifier of the db connection in the report. hope this helps someone. https://stackoverflow.com/a/35545586/3013470
rekjcdws6#
I battled with this problem for weeks on and off trying to deploy a Click-Once app and finally found it to be that the client computer needed the SQL Native client installed for SQL 2012; so, I had to add that to my prerequisites.
bhmjp9jg7#
I have just come across a similar issue, where suddenly a lot of reports stopped working on a server. after a lot of head scratching i found a resolution was to open the report in design view, and re-locate the database by creating a new connection...
after this the reports worked fine... hope this helps someone.