on 09-06-2008 11:48 AM
Hi friends,
After going through it what is your opinion. please do post your opinion.
Could any one give the complete steps of Linking a report to web form so that when called / clicked the link the report can display the data.
I have unchecked the "Report Option -> Save Data with Reports". So that the report could not take extra space.
I have DB connection code in my .aspx.vb file, it is as follows:
Private Sub ConfigureCrystalReports()
Dim fileName As String = "Reports\" & ReportID & ".rpt"
Dim reportPath As String = Server.MapPath(fileName)
myRepDoc = New ReportDocument()
myRepDoc.Load(reportPath)
myCrystalReportViewer.ReportSource = myRepDoc
myCrystalReportViewer.RefreshReport()
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
If Session("reportConnectionInfo") IsNot Nothing Then
Dim ConnInforArrList As ArrayList = DirectCast(Session("reportConnectionInfo"), ArrayList)
myConnectionInfo.ServerName = ConnInforArrList(0)
myConnectionInfo.DatabaseName = ConnInforArrList(1)
myConnectionInfo.UserID = ConnInforArrList(2)
myConnectionInfo.Password = ConnInforArrList(3)
Else
lblMessage.ForeColor = Drawing.Color.Red
lblMessage.Text = "Session is off. Please Relogin to See the Report."
End If
SetDBLogonForReport(myConnectionInfo, myRepDoc)
SetDBLogonForSubreports(myConnectionInfo, myRepDoc)
myCrystalReportViewer.SelectionFormula = GetFieldName(ReportID) & "='" & Session("CompCode") & "'"
myCrystalReportViewer.Visible = True
End Sub
Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
Dim myTables As Tables = myReportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
End Sub
Private Sub SetDBLogonForSubreports(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
Dim mySections As Sections = myReportDocument.ReportDefinition.Sections
For Each mySection As Section In mySections
Dim myReportObjects As ReportObjects = mySection.ReportObjects
For Each myReportObject As ReportObject In myReportObjects
If myReportObject.Kind = ReportObjectKind.SubreportObject Then
Dim mySubreportObject As SubreportObject = CType(myReportObject, SubreportObject)
Dim subReportDocument As ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
SetDBLogonForReport(myConnectionInfo, subReportDocument)
If myReportObject.Name = "Subreport1" Then
Dim lvSec As Section = subReportDocument.ReportDefinition.Sections("DetailSection1")
If Not lvSec Is Nothing Then
Dim t1 As TextObject
t1 = lvSec.ReportObjects("txtEmpName")
t1.Text = Session.Contents("EmpName")
Dim t2 As TextObject
t2 = lvSec.ReportObjects("txtRepID")
t2.Text = Request.QueryString("REPID")
End If
End If
End If
Next
Next
End Sub
Please do help me out as the data of report is not getting displayed on the report.
After going through it what is your opinion. please do post your opinion.
While creating the Report has the following Report Options on / checked.
1. Database Server is Case-Incensitive
2. Use Indexes Or Server For Speed
3. Verify on First Refresh
4. Show Preview Panel
5. Display Alerts on Refresh
6. Select Distinct Data for Browsing
Do I have check or uncheck any other option?
Thanks and regards
Edited by: Md. Mushtaque on Sep 6, 2008 2:50 PM
Edited by: Md. Mushtaque on Sep 8, 2008 9:27 AM
Edited by: Md. Mushtaque on Sep 8, 2008 12:14 PM
Hi there,
A few comments / suggestions:
1. When posting code using the code tags. When you type your post you can see on the right some tags that you can use. That way your code is easy to distinguish from the rest of your post.
e.g.
Some Code Goes here
2. In your code you have this section:
If myReportObject.Name = "Subreport1" Then
Dim lvSec As Section = subReportDocument.ReportDefinition.Sections("DetailSection1")
If Not lvSec Is Nothing Then
Dim t1 As TextObject
t1 = lvSec.ReportObjects("txtEmpName")
t1.Text = Session.Contents("EmpName")
Dim t2 As TextObject
t2 = lvSec.ReportObjects("txtRepID")
t2.Text = Request.QueryString("REPID")
End If
End If
which doesn't seem to be needed to display the report. I suggest that you first get the report displaying before going into anything extra. So please remove this section.
3. In this section of code:
Dim fileName As String = "Reports\" & ReportID & ".rpt"
Dim reportPath As String = Server.MapPath(fileName)
myRepDoc = New ReportDocument()
myRepDoc.Load(reportPath)
myCrystalReportViewer.ReportSource = myRepDoc
myCrystalReportViewer.RefreshReport()
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
If Session("reportConnectionInfo") IsNot Nothing Then
Dim ConnInforArrList As ArrayList = DirectCast(Session("reportConnectionInfo"), ArrayList)
myConnectionInfo.ServerName = ConnInforArrList(0)
myConnectionInfo.DatabaseName = ConnInforArrList(1)
myConnectionInfo.UserID = ConnInforArrList(2)
myConnectionInfo.Password = ConnInforArrList(3)
Else
lblMessage.ForeColor = Drawing.Color.Red
lblMessage.Text = "Session is off. Please Relogin to See the Report."
End If
I would remove the lines:
myCrystalReportViewer.RefreshReport()
and
If Session("reportConnectionInfo") IsNot Nothing Then
Just get everything hard-coded first - then you can start adding some if-then statements.
4. Lastly - you need to be calling this from your Page_Init method. If you are calling it from your page_load method - it may not work.
Other than that - your code looks ok (given that it is copied directly from one of our samples) - and the options set on your report look fine.
Regards,
Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sir Shawn,
I have just tried as per your instructions.
1. I have removed the extra section
2. Removed
myCrystalReportViewer.RefreshReport()
and
If Session("reportConnectionInfo") IsNot Nothing Then
3. The code has been called from Page_Init method only.
Till now the report shows the same, means blank report, no data from database.
I have tested that if the
Report Option - Save Data With Report is ON / CHECKED
then the report shows the data on calling from web form but if it is
OFF/UNCHECKED
then again the report shows blank.
If you could please provide any sample which is tested and working fine and the
Report Option - Save Data With Report is OFF/UNCHECKED.
It will be thankful to you.
One more thing the database I am using is Oracle 10g.
Edited by: Md. Mushtaque on Sep 11, 2008 9:34 AM
Sir/Madam,
Please look into this problem it is getting serious day by day.
Well I make it clear that now I am using the trial version of Crystal Report 2008 of 60 days.
This problem is not getting solved by all my effort, so please do some needful, it will be very kind of you all and I will be very thankful to you.
Please put an eye on the problem and give your opinion to solve the problem.
Thanks and regards
HI,
If you would like create a simple windows application and pass this code,
//Namespaces
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows;
//code in page Load.
ReportDocument rdoc = new ReportDocument();
rdoc.Load(path of the report);
CrystalReportViewer1.ReportSource = rdoc.
this might ask for database credentials and parameters, pass them at runtime. For more simplicity use some sample reports in your machine.
If this works then use the following to pass database credentials and parameters to report:
Reportdocumentobject.SetParameterValues(parameter name, value);
Reportdocumentobject.SetDataBaseLogon("uid","Password");
Hope that helps!
AG.
Sir AG,
Thanks a lot for replying and spending your valuable time for my problem.
Sir, I just want to put this in your knowledge that my application is web based application and I am calling these reports through web forms i.e. of ASP.NET coded in vb from .aspx.vb files.
So as per the code I have attached, I have this
Option Explicit On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Next for ReportDocument Object:
Dim fileName As String = "Reports\" & ReportID & ".rpt"
Dim reportPath As String = Server.MapPath(fileName)
myRepDoc = New ReportDocument()
myRepDoc.Load(reportPath)
myCrystalReportViewer.ReportSource = myRepDoc
Above is the code used by me in Page_Init and I have already tested it from Page_Load. I have got few suggestions from this forum that I should put this code in Page_Init only.
Lastly:
The database connectivity code:
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
If Session("reportConnectionInfo") IsNot Nothing Then
Dim ConnInforArrList As ArrayList = DirectCast(Session("reportConnectionInfo"), ArrayList)
myConnectionInfo.ServerName = ConnInforArrList(0)
myConnectionInfo.DatabaseName = ConnInforArrList(1)
myConnectionInfo.UserID = ConnInforArrList(2)
myConnectionInfo.Password = ConnInforArrList(3)
Else
lblMessage.ForeColor = Drawing.Color.Red
lblMessage.Text = "Session is off. Please Relogin to See the Report."
End If
SetDBLogonForReport(myConnectionInfo, myRepDoc)
SetDBLogonForSubreports(myConnectionInfo, myRepDoc)
SetDBLogonForReport(myConnectionInfo, myRepDoc)
Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
Dim myTables As Tables = myReportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
End Sub
This code I have got from a sample of the forum itself.
Sir, after all these effort and the unchecking of option "Save Data with Report" on calling the reports from my forms it is showing blank report. No data from the database is coming form the database.
I have uncheked the option "Save Data with Reports" to get the updated data each time the report has been called but now the status is that nothing is coming.
Thanks again for you precious and valuable effort to help me but the my problem is unsolved, So sir please if you could put an eye on it and help me out to get rid of this problem, I will be very thankful to you for your kind help.
Thanks and regards
Mushtaque
Hi,
From the last post I could understand that you have used the Simple code along with the Connection info also. Can we remove the connection info code and just stick to the following lines only:
Dim reportPath As String = Server.MapPath(fileName)
myRepDoc = New ReportDocument()
myRepDoc.Load(reportPath)
myCrystalReportViewer.ReportSource = myRepDoc
I hope you are not changing database at runtime. If you are then map the report to the target database and save it. Use the same database to view the report from the application. How does it behave?
I would prefer testing this in a windows application rather than a web application to remove issues like permission and configuration made in web.config files etc, which makes it hard to pin point the issue at this point of time. So, lets see till where we can walk properly where the report is failing.
If this fails then then try the following step to check the db connectivity:
1. Create a txt file in the machine and change the extension to udl.
2. Open the udl file.
3. Select the same provider, database from drop down (I would suggest not to type the name rather select it from the drop down box),pass the credentials.
4. Click on the Test Connection, it should come as Success.
If it does not check the database connectivity.
Make the reports more simple, remove subreports. Pass report name, at later stage parameter, credentials through code but hard code them. There are a lot of things in the code you provided in the first post, I would suggest you to use a new wind app and try so that we can isolate the issue. Did you try with sample reports in your machine? Does it display properly? Are you using ODBC or OLEDB connectivity? I believe the issue is coming from dev machine, am I right? Is the issue with this report or will all the reports? Do the report display proper data from designer?
Let us know if this helps!
Regards,
AG.
Edited by: AG on Sep 14, 2008 1:59 AM
Edited by: AG on Sep 14, 2008 2:05 AM
Sir,
Thanks a lot again.
Here are the answers of your questions.
Did you try with sample reports in your machine?
Yes, I did.
Does it display properly?
Yes, they display properly. The sample report is having SQL Database, which is saved in the same directory with reports.
Are you using ODBC or OLEDB connectivity?
Sir, I am using Oracle Server
I believe the issue is coming from dev machine, am I right?
Yes, the issue is from dev machine as well as from any machine in the network. As this is a web application and we have tested it after configuring the web site in IIS Server and run it from dev machine and other machines too.
Is the issue with this report or will all the reports?
Yes, this issue is with all the reports which are saved with u201CUNCHECKED - Save Data with Reportsu201D
Do the report display proper data from designer?
Yes, it displays proper, complete and updated data from designer.
The report/result of steps given by you I will post it after testing. Till then bye and Thanks for all your help.
Thanks and regards
Sir,
I removed the database connectivity code and run the program.
This gives the result that It opens the window for report and asks to enter the connection information,
where it allowed only
to enter the password in password textbox,
other than that
Server textbox is having the server name,
Database textbox is blank and readonly,
User name textbox is having the user name.
Well after entering Password, I clicked on the (Log on) button but the report does not displayed only it hide the password textbox.
I could not understand that what is this matter.
Well you are experienced and can understand why this happened.
Next I will test and again post the result
Thanks and regards
Hi,
The report prompts for database credentials like User id and Password when it tries to get connected to the database and repeats it-self if some connection or tables are lost or dropped. So make sure that the report runs fine from the designer, to be more sure in the Field explorer, right click on the Database fields and go to set datasource location, in the new window create a exact same but new connection, select the fields in "replace with" section with the same table in "Current data source"window, click on Update button, remap the fields if there are any new or unmapped fields.
Let us know if that helps with answers to the questions asked before.
Thanks,
AG.
If this issue is getting really time-critical for you - you may want to try creating a support case with BO support for some more support.
I would also recommend trying some sample code since usually samples are in a known working state - you can find some samples to download here:
https://boc.sdn.sap.com/codesamples
Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
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.