For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Crystal Reports > May 2005 > set Crystal Report database path from code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author set Crystal Report database path from code
mf_sina

2005-05-23, 3:58 am

Hi all

i have a form and a crystalreportviewr control on that form.
crystalreport1 is my report which must use database1.mdb as it's datasource.
now how can i set the database path of my crystal report from code when form
loads?
(i'm using VB .Net)
thanks


Charles A. Lackman

2005-05-25, 8:58 pm

Hello,

Before the form loads create a new instance of the CrystalReport and all its
properties. Most of the time it is better to use a dataset that is filled
with the data from the database instead of running the CrystalReport in a
connected state (connected to the database).

Dim TheCrystal as New MyCrystalReport
TheCrystal.SetDataSource(ADataset) ' If using a dataset to populate the
report/I believe you can also use the file location "C:\database1.mdb"
Form1.CrystalReportViewer1.ReportSource = TheCrystal
Form1.ShowDialog()

When using Crystal Reports and Datasets you have to create a dataset from
inside the VS designer then populate the dataset before you send it to the
report. After you have created the dataset, Crystal Reports will allow you
to see it inside the designer and place the fields onto the Crystal Report.

Hope this helps,

Chuck

"mf_sina" <mf_sina@yahoo.com> wrote in message
news:un5iIR1XFHA.1240@TK2MSFTNGP14.phx.gbl...
Hi all

i have a form and a crystalreportviewr control on that form.
crystalreport1 is my report which must use database1.mdb as it's datasource.
now how can i set the database path of my crystal report from code when form
loads?
(i'm using VB .Net)
thanks



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com