Binding DataTable to a Crystal Report

S

ShiTvm

Hi,

Which is the best way to bind DataTable to a Crystal Report in Winforms
application.
I am using a stored procedure to get the dataset. But I could'nt find a
proper documentation for how to bind the DataTable or DataSet to a Crystal
Report.

Any suggestions..
Rgds
Shibu
 
N

Norman Yuan

There are two ways to get data into Crystal Report.NET: PULL and PUSH. What
you want is PUSH. That is, prepare you data in DataSet/DataTable, and push
it into report when the report is loaded.

Look for ReportDocument.Database.Tables.Item("tablename").SetDataSource()
method.
 
V

Vincent Dalton

Create a Typed DataSet from the "Add New Item > DataSet and give the dataset
a useful name.

In Server Explorer, drag a view with the fields you want in the report onto
the dataSet.

Create a new Crystal Report using the Wizard.

From the Report Gallery, choose "Standard" and click 'OK'

In the 'Data' tab, click the node for "More Data Sources"

Click the node for ADO .Net (XML)

Check the box for 'Use Visual Studio Data Class'

In the 'Visual Studio Data Class name' combobox, select the name of the
dataset you just created.

click 'Finish'

Choose the table displaying under the name of the dataset you just added to
the 'Data' tab and click 'Insert Table'

Format your report. When you go to display it, use the code below as an
example.



Vince Dalton

Dim rpt As New rptCompany_Addresses

Dim dsCompany_Addresses As New dsCompany_Addresses

Me.conORA.ConnectionString = ConnectionParams.oraDB

daCompany_Addresses.Fill(dsCompany_Addresses, "COMPANY_ADDRESSES")

rpt.SetDataSource(dsCompany_Addresses)

crptViewer.ReportSource = rpt
 

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