on 12-31-2009 7:50 PM
I've developed an ASP.NET application with a Crystal Reports viewer. I used VS 2008, Crystal 2008, connecting to a SQL 2005 database. I used a System DSN ODBC to connect to SQL in the Crystal Report. My report works fine, both on my development machine and on the Web Server if the Save Data with Report is checked. My issue is that once I uncheck the 'Save Data with Report' option, I get prompted for a database login running the report off of the web server. I haven't seen anything definitive for an answer while searching the forums.
I've tried to create an odbc connection and use 'Trusted Connection', and re-map my DataSource, but that did not work. I also unchecked the EnableDatabaseLoginPrompt on the Report Viewer in VS.NET, no luck there either. What else can I try?
Still no luck. This is what I have for code to load the report:
Try
Dim myReport As New ReportDocument()
myReport.Load("C:\PhoneDirectory.rpt", OpenReportMethod.OpenReportByDefault)
myReport.DataSourceConnections(0).IntegratedSecurity = True
CrystalReportViewer1.ReportSource = myReport
Catch ex As Exception
MsgBox(Err.Description)
End Try
I set the Directory Security Access on my Virtual Directory to Anonymous Access as the document specifies.
I also added this line to my web.config file:
<identity impersonate=u201Dtrueu201D />
Now, when this line is in my asp.net app, I get the message: Load Report Failed
When I don't have the line above in, I get the message(which I had been getting): Database logon failed.
In both cases, the report loads fine on my development machine. We're close, but I'm missing something.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue. Works fine on my development machine. I copied my report to the same directory as where the web page is housed and I got the 2 different error messages as I indicated above, depending on whether or not I have this line of code in the web.config file:
<identity impersonate=u201Dtrueu201D />
Is it a problem as far as where I have this line of code above? I have the code in my web.config as follows:
<authentication mode="Windows"/>
<identity impersonate="true" />
Joe
I opened up a support case and I got my question answered. Here's what you need to do to get your asp.net application working.
In the Page_Load sub in the website.aspx.vb code, add this code in:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim myReport As New ReportDocument()
myReport.Load(Server.MapPath("ReportName")) 'name of your Crystal Report - see note below
Dim myTables As Tables = myReport.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myConnectionInfo.ServerName = <SQL servername>
myConnectionInfo.DatabaseName = "" 'leave database name blank
myConnectionInfo.UserID = 'login name
myConnectionInfo.Password = 'password
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
CrystalReportViewer1.ReportSource = myReport
A couple of more things:
Add your Crystal Report as an existing item directly to your project. This will push the report out with your webpage to the web server once you publish your application.
Only add the Crystal Report Viewer to your application.aspx page. Leave the Report Source blank. The code above will set your report source.
Hope this can help out someone else in the future!
Hello,
I am developing an ASP.NET application using crystal reports in it, I suffered trying to remove or bypass that logon security popup but nothing was useful, please help, knowing that I am connecting to mysql database for this report,
Thank you.
Regards,
Amira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amira
You attached your self to a Discussion that is 5 years old. Please do create a new discussion and have a look at the following blog re. what info to provide:
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow me on Twitter
Jonathan,
A couple of questions with the link you referenced:
I'm using Crystal 2008 - Will this code work with my version of Crystal?
What does this line of code mean, specifically, SQLReport_LocalDBRpt? How/Where do I find/reference SQLReport_LocalDBRpt?
Dim report as new SQLReport_LocalDBRpt
Finally, the document mentions this:
This document applies only to the scenarios where the application and the database server reside on the same computer.
My application is deployed to a web server and my database is on a different database server. It sounds like I can't use these code samples?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Joe;
Yes, it should all work fine with CR 2008.
The SQLReport_LocalDBRpt it refers to is a report that was added to the project. For CR 2008, you would have to Load a report from disk, ie:
Dim myRpt as new ReportDocument
myRpt.Load ("C:\Reports\report1.rpt")
That line doesn't make much sense to me, as who has the database server and web server on the same system. Disregard, as most people are doing this, and it should work just fine.
Regards,
Jonathan
Hi, Joe;
Is it your intention to do a trusted connection, or are you just looking for any thing that works? A trusted connection gets a little tricy with a web application, but it can be done.
An easier solution could be passing in the user id and password in code.
Have a look at the following guide for some tips on this:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0225775-88c4-2c10-bd80-8298769293de
Happy New Year
Jonathan
Follow us on Twitter http://twitter.com/SAPCRNetSup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Joe;
Have a look at this document, it should get you going:
Regards,
Jonathan
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.