Saturday, December 26, 2009

How to avoid “The report you requested requires further information” when you try to connect Crystal report using ASP.NET


Some times when you run a Crystal report using ASP.NET you will get the error

“The report you requested requires further information”.

I got this error when I tried to connect AS/400 using iSeries ODBC Drivers

See figure 1.











Figure 1 the error message

You get this error because your DSN is not able to pass log in info to your crystal report.

There is 2 ways to solve this problem


1:- Save user and password information in your DSN.

This solution is good when the DSN allow you to save User and Password

For example DSN that connected to Sql Server .

See Figure 2

















Figure 2

2:Pass User and Password information to crystal report
Pass User and Password info by using report document to your report.

You can pass log in info by using SetDatabaseLogon(User,Password) property.

Also you should verify database by using VerifyDatabase() method to pass log in info.


Example:

In this example my Crystal report get customer number as parameter and display customer info.

The report name is "cusrep.rpt"

The ASP.NET page get customer number as parameter “cusnum”.

The parameter name in crystal report is “CUNO”.

The report viewer control name is “myCrystalReportViewer”.

At page load event the program get the parameter and display te report,

P.S : do not forget to import crystal classes.


Imports CrystalDecisions.CrystalReports.Engine

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim MyRep, Myfile As String

MyRep = "cusrep.rpt"
customerReport = New ReportDocument()


'******** Load the report

Dim reportPath As String = Server.MapPath(MyRep)

customerReport.Load(reportPath)

'******** Pass log in info

customerReport.SetDatabaseLogon("Db user", "Db Password")

'******** Verify Data base

customerReport.VerifyDatabase()

'********* Pass parameter and display report

myCrystalReportViewer.ReportSource = customerReport

myCrystalReportViewer.ParameterFieldInfo.Clear()

Dim ParamFields As ParameterFields = myCrystalReportViewer.ParameterFieldInfo

Dim Rep01 As New ParameterField

Dim CusNum As String

CusNum = Request("cusnum")

Rep01.Name = "CUNO" '

Dim Rep01_Value As New ParameterDiscreteValue

Rep01_Value.Value = CusNum

Rep01.CurrentValues.Add(Rep01_Value)

ParamFields.Add(Rep01)

For Each cnInfo As TableLogOnInfo In Me.myCrystalReportViewer.LogOnInfo

cnInfo.ConnectionInfo = ConnInfo

Next

myCrystalReportViewer.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX

End Sub



1 comment:

  1. Hi,
    Need a favor..
    Do you know how to view the current record in Crystal Report when click on gridview Linkbutton.
    Thanks
    Aleesya

    ReplyDelete