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



Monday, December 21, 2009

ODBC Connection String FAQ

Everything you always wanted to know about ODBC connection strings and the iSeries.
When using ODBC to talk to the AS/400, you can use a data source name to connect or you can use a connection string with all of the relevant settings in the string you pass to the ODBC Driver. A data source name stores ODBC information in the Windows registry after you use the ODBC Data Source Administrator to configure your data source. The problem with data source names is that each time you attempt to connect; the program has to look up information about the connection options in the Windows registry. If you are programming a web application, you could be issuing hundreds of connections to the iSeries a minute, and the performance hit of reading the registry is not something you want to have in your application. Another problem with data source names, if you are deploying ODBC applications to end users, is that you must set up the data source on the end users machine as part of your program installation process. This can be problematic, and if the desktop is not properly configured you end users can futz with their ODBC settings and possibly make changes the break the application. All of the above can be avoided by using a connection string rather than using an ODBC data source name when connecting. In addition, you will have finite control over how you application interacts with the iSeries.

Read this article Read this article Read this article Read this article