Question Crystal reports with Access

helderjsd

Member
Joined
Mar 29, 2010
Messages
8
Programming Experience
1-3
Hello.

I was made an application in VB.net 2008, and a report with Crystal Reports.
When I create the report, I have created i new connection in crystal reports design, for conect to my MDB.

My question, was the application can be installed in anywhere on the computer, and the CR loss the path for the right path to the MDB file.

Then, I wanna use the property application.startuppath for CR knows where the mdb was.

But.... Doing a test with another MDB in a fix directory, it doesn't work.

I us ethis code in the load event of my form:

Dim cryRpt As New CrystalReport1
Dim crConnectionInfo As New ConnectionInfo

With crConnectionInfo
.ServerName = "c:\tmp\abcdef.mdb"
.DatabaseName = "c:\tmp\abcdef.mdb"
End With

CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()

The CR never goes pick the data from my folder TMP. Allways use the static MDB define in the CR design

What can I do more????
 
This would require a redesign of your report but I think it is easier to base your report on a Typed Dataset, rather then your database. Then you can control what data is filled into your dataset and just pass the filled dataset to the report.
 
Hum..

It's an ideia...

But, tell me following:

After I create my dataset and populate them, and can I pass my dataset to the Crystal report??
 
Yes but now your changing just your applications connection string which you would have to do anyway. Looking at your code snippet, I dont see you setting any datasource to your report at all...

Dim cryRpt As New CrystalReport1
Dim crConnectionInfo As New ConnectionInfo

With crConnectionInfo
.ServerName = "c:\tmp\abcdef.mdb"
.DatabaseName = "c:\tmp\abcdef.mdb"
End With

CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()

You have a connectioninfo object thats not connected to your report and set the report source of your viewer control but not the report itself
 
Now, I'm confused...

Can you send me an example of connecting the dataset??

With this, it will be catch the file I was marked in design mode
 
When you first create a report, your pointing it to your database and selecting your tables & fields. You could instead create a typed dataset in your project, create your report based on the dataset instead of your database and then just pass the filled dataset to your report.

rpt.SetReportSource = myDataset
 
Back
Top