Monday, 19 March 2012

Connect to .mdb Database in Crystal Report 9 from VB

Hi,

Some one Pls tell me How to connect to a .mdb file from Visual Basic

Am using Crystal Report 9.

I have created a CRAXDRT. Application and Report and I have opened the Report.

How should I pass the database name (.mdb) after this..

I want to add App.Path also when I connect to the database

Thanks
PremodDim CrxRep As New CRAXDDRT.report
Dim CrxApp As New CRAXDDRT.Application
Dim CrxDataFiles As CRAXDDRT.DatabaseTables

strDBPath = "Path to DB Goes Here"

Set CrxRep = CrxApp.OpenReport(App.Path & "\CrystalRpt\BPOilAnalysis.rpt", 1)
Set CrxDataFiles = CrxRep.Database.Tables
CrxDataFiles(1).SetLogOnInfo (strDBPath)

I used this code since my DB path can change and wanted it to remain versatile to the user.

Hope this helps! Tricia =)

No comments:

Post a Comment