Crystal Reports in ASP.NET using Stored Procedure

S

Saravanan

Hi,
I'm trying to use our existing Crystal Reports .rpt while trying to migrate
from existing ASP to ASP.NET.
Current Crystal reports all have a datasource which is .ttx having the
format fields required to be populated by the stored procedures externally
thru ASP(i.e data table/Stored procedure is not embedded in the .RPT).
While trying to use the same .RPT in ASP.NET web forms, after I try to bind
the CrystalReportViewer with the data from a dataset/dataadaptor, when I run
the report, I get a blank report. Meaning, only the report format got bound
but not the data. How do I bind the CrystalReportViewer with a .rpt
reportsource with data from a storedProcedure? I read Microsoft guides but
could not break the shackles.
Any help in this regard would be highly appreciated.
Thanks in advance,
 
E

Elton Wang

Hi Saravanan,

To bind CrystalReportViewer with CrystalReport:

CrViewObject.ReportSource = CrObject;

There are several ways to bind CrystalReport's data
source. One way is to set the report's database logon
info, so the report can log on database to get data either
via SP or its sql query. Another way is to create
datatables that have exact same schema with report's query
or SP query. Then fill data to datatables by dataadapter
and bind these datatables with report's data source.

The first method has good performance, and the second is
more flexible.


HTH

Elton Wang
(e-mail address removed)

-----Original Message-----
Hi,
I'm trying to use our existing Crystal Reports .rpt while trying to migrate
from existing ASP to ASP.NET.
Current Crystal reports all have a datasource which is .ttx having the
format fields required to be populated by the stored procedures externally
thru ASP(i.e data table/Stored procedure is not embedded in the .RPT).
While trying to use the same .RPT in ASP.NET web forms, after I try to bind
the CrystalReportViewer with the data from a
dataset/dataadaptor, when I run
 
S

Saravanan

Hi,
My code is like this:

Dim dsCollRpt As New DataSet
Dim rpt As New CrystalReport1
Dim con As New SqlConnection(ConfigurationSettings.AppSettings("conn"))
Dim cmdCollRpt As New SqlCommand

cmdCollRpt.Connection = con
cmdCollRpt.CommandText = "select
rank,PartCode,'',PartDesc,QOH,LandedCostAverage,'','','',location from
PartInventoryMaster where QOH <> 0 order by rank"
cmdCollRpt.CommandType = CommandType.Text

Dim dacollrpt As New SqlDataAdapter(cmdCollRpt)

dacollrpt.Fill(dsCollRpt)
rpt.SetDataSource(dsCollRpt)

CRV1.ReportSource = rpt
'CRV1 is the Crystal ReportViewer
CRV1.DataBind()

As I hav ementioned before, the Crystal Report does not have a table/stored
procedure bound inside but only a format file as DataSource which is .ttx
file.

Hope you can guide me now.
Rgds,
 
E

Elton Wang

Hi Saravanan,

It doesn't matter to use data definition file (ttx) in CR.
The ttx only gives data structure in report. At running
time the CR report still requires data. So if you fill
datatable (In my experience don't use DataSet!!!!) in the
same structure as ttx, then :

report.SetDataSource(datatable)
CrystalReportViewer1.ReportSource = report

It should work.


HTH

Elton Wang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top