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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Database at Runtime

Status
Not open for further replies.

LeanneK

Programmer
May 3, 2002
8
0
0
US
I would like to dynamically change the database from which I pull records. I tried creating an ADO connection and recordset (rs) and used the following code to link the "new" table to the report:
Report.Database.SetDataSource rs
This, however, does not appear to work. The report is still pulling records from the original database.


 
Let me second this query. I'm trying the same thing in VB.NET and can't get the data source to set.

Any ideas? Anyone?

-Brian
 
I may have a solution:

Try setting each table in the report's dataset to a single table in the new dataset.

My code:

objLoad is an instance of a class that exposes a dataset containing three tables. It exposes the dataset to make printing reports easier. objReportHost is a vb form that contains the report viewer.

objReport.Database.Tables.Item(0).SetDataSource
(objLoad.LoadDataSet.Tables(0))
objReportHost.CrystalReportViewer1.ReportSource = objReport

objReportHost.CrystalReportViewer1.RefreshReport()
objReportHost.Show()


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top