Using Crystal Reports with ASP.NET

K

Khurram

Hi,

I am trying to use Crystal Reports with ASP.NET. I created a dataset
and tried to display it in the report but nothing came up. I did not
get an exception either. I know that the dataset is populated so it
has to be a very basic binding issue.

To bind the report object to dataset I called the SetDataSource method
of Report object with dataset as the parameter.

To see the report I set the ReportSource of crystal report viewer
object with the report.

Is there anything else I need to do?

Thanks
 
K

Ken Onweller \(.NET MCSD\)

When you use your DataAdapter to load the dataset, be sure to specify the
EXACT same name
of the table as you specified when creating the dataset schema that you used
in the report
designer.

i.e.

da.Fill(ds,"mytable");
 
K

Khurram Lone

Ken,

What I am trying to do is something very basic. I created a blank
crystal report. Then I created a recordset with a query to the database.
I checked that the recordset was populated. Then I called the
SetRecordSet method of the Crystal Report object. When I displayed the
report in the report viewer, it came up blank.

I was not sure that a blank report could be bound to a recordset, so I
created another report which I bound to a database table. Then I did a
query on that same database table, created a recordset, and passed that
recordset to the report object. The recordset was populated with the
same fields as the report. The fill method of the dataadapter has the
exact same table name as the report.
The report came up in the report viewer populated by the entire table,
once again as if the recordset had not been sent to the report.

Thanks

Khurram
 
K

Ken Onweller \(.NET MCSD\)

I dropped a viewer on a form.

here's the code for my form that pulls three sprocs into a dataset and
binds it to the report:
public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

// create an instance of our strongly typed dataset and

// fill it with data from the database

Dataset1 ds = new Dataset1();

SqlConnection conn = new SqlConnection(

"workstation id=HTKENWS;packet size=4096;integrated security=SSPI;" +

"data source=\"HTKENWS\\SPAMSPAM\";persist security info=True;initial
catalog=pubs");

SqlDataAdapter da1 = new SqlDataAdapter(

"exec getauthors", conn);

SqlDataAdapter da2 = new SqlDataAdapter(

"exec gettitleauthors", conn);

SqlDataAdapter da3 = new SqlDataAdapter(

"exec gettitles", conn);

da1.Fill(ds,"getauthors");

da2.Fill(ds,"gettitleauthors");

da3.Fill(ds,"gettitles");

// instantiate our report and bind bind the strongly typed dataset to it

CrystalReport1 rpt = new CrystalReport1();

rpt.Database.Tables[0].SetDataSource(ds);

// bind the report instance to the gui

crystalReportViewer1.ReportSource = rpt;

rpt.PrintToPrinter(1,true,1,2);

}
 

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

Top