Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Dataset to a RPT in dotnet

Status
Not open for further replies.

pkpatel

Programmer
Jul 23, 2003
3
US
Hi,

I am trying to generate a dynamic report with VB.net. I have included a report in the project, I am asking the users to provide me with parameters by which I can generate a sql statement, pass it to the db and pass the resulting dataset to the included report. I have tried using the paramaterized variables in the report itself but that is not providing a solution.

Any help is appreciated.

Thanks

Pranav
 
I've done this two different ways with CrystalReports in ASP.NET: 1) set the selection formula in the report dynamically and 2) generate the SQL data dynamically. You may only need to do one depending on your requirements. Here's some code:

'In ASP the following code should be inserted into the sub Page_Init() procedure.
'also you'll need to design your report using a design time dataset and save the report to the project.

Dim rep as new CrystalReport1

OleDbDataAdapter1.TableMappings.Clear()
OleDbSelectCommand1.CommandText = "Select * From cost_centers Where Id=1234 And Name Like 'Bush*'"
OleDbDataAdapter1.Fill(DS1, "cost_centers")

rep.SetDataSource(DS1)

With CrystalReportViewer1
.SelectionFormula = "{budget_entries.ds_fscl_year}='" & sFiscal & "' " & _
"And {budget_entries.cd_run}='" & sRun & "'"
.ReportSource = rep
End With

Good luck.
 
Thanks Alex, I will give it a shot. I am working with a Sql2000 box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top