run-time binding in crystal reports

Rajya

Member
Joined
Apr 15, 2005
Messages
22
Location
Calcutta, India
Programming Experience
1-3
Hello

I am using VB.NET for developing an application.

For reporting, I am using Crystal Reports for .NET - how do I bind the report fields at run-time / dynamically. I would not like to use the Wizards / Experts.

Please advise.
 
Nah ... Wizards / Experts are for begginers only :D JK of course :)

However if i understand your q you have three available scenarios how to insert a text on your crystal report from vb.net:

1st one is via a parameter like standard communication between VB.NET and a report. 2nd via a text object and 3rd via a formula.

Just for a case that you want to know about how to producing a Crystal Report using a dataset rather but insert a text only like i pointed out above this might be helpful to be known.

First off, ensure that your dataschema is complete and that Imports at the start of your code are like it follows:

PHP:
Imports System.Data.OleDb 'or other driver that you are working with
Imports CrystalDecisions.CrystalReports.Engine 
Imports CrystalDecisions.Shared


then:
PHP:
Dim myReport As CrystalReport1 
myReport = New CrystalReport1() 
myReport.SetDataSource(myDataSet) 
CrystalReportViewer1.ReportSource = myReport 
CrystalReportViewer1.DataBind() ' bind the report object and data

That was very short i know but i hope enough for you to get the basic stuff about this way of producing a CR.

If you need an additional assistence feel free to ask for more help ... i'd be glad to help you out.

Cheers ;)
 
run-time binding in crystal reports Reply to Thread

Thanks for the help :)

I have implemented your code (except that I could not find the CrystalReportViewer1.DataBind() method), but the report is coming out all blank. Where am I going wrong?

In the report design (PD_Report.rpt - see code below), I have just put two unboundstrings and set their Name properties to the column names of the Table in the Filled Dataset - the latter is getting Filled okay - see the commented Messagebox.Show statement.

Code Start ------------------------------->
Private Sub mnuReports_Info_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuReports_Info.Click


With cEssentials
.cSqlCommand = New SqlClient.SqlCommand
.cSqlDataAdapter = New SqlClient.SqlDataAdapter
.cDataSet = New DataSet
frmReportForm = New ReportForm 'The Form on which the Report Viewer will display the report
frmReportForm.MdiParent = Me
rptPersonalData = New PD_Report 'Instantiating a New Report object


.cSqlCommand.Connection = gConn

.cSqlCommand.CommandType = CommandType.StoredProcedure
.cSqlCommand.CommandText = "Entire Address Table"
.cSqlDataAdapter.SelectCommand = .cSqlCommand


.cSqlDataAdapter.Fill(.cDataSet, "Address")



'.cDataTable = .cDataSet.Tables("Address")

'MessageBox.Show(CStr(.cDataTable.Rows(0).Item("Fname")) & " " & CStr(.cDataTable.Rows(0).Item("Lname")))


rptPersonalData.SetDataSource(.cDataSet)

frmReportForm.CrystalReportViewer1.ReportSource = rptPersonalData
frmReportForm.Show()


End With

End Sub
Code End ------------------------------->
 
Back
Top