[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

How to assign database password while calling crystal report from VB application.

Hi
From My VB  application I m calling one crystal report  , I m using  access  database ,
But after setting up  password to database  while calling report I need to provide database password . please write me code  for providing  database password while calling  Crystal report .
Here my sample code of VB application from where I m calling  crystal report is .

Private crApp As CRAXDDRT.Application
Private crRpt1 As CRAXDDRT.Report

Private Sub Form_Load()
Set crApp = New CRAXDDRT.Application
Set crRpt1 = crApp.OpenReport("c:\report.rpt", 1)

Me.CRViewer91.ReportSource = crRpt1

Regards
0
rehman123
Asked:
rehman123
  • 4
  • 3
1 Solution
 
rehman123Author Commented:
mmlc that sample example itself not working giving error  like . ca'nt find project or library .
please in my mentioned code write syntax of setting up password .
0
 
rehman123Author Commented:
I added logonserver  parameter  crRpt1.Database.LogOnServer "PDS*.DLL", "database_name", "", "", "password"
but it gives error
Runtime error '91'
Object variable or with block variable not set
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
GJParkerCommented:
For intTables = 1 To CrRpt1.Database.Tables.Count
      CrRpt1.Database.Tables(intTables).ConnectionProperties.Item("Password") = ""
Next intTables

The best way is to loop through the repert database tables and assign the password.

Gary

0
 
rehman123Author Commented:
GJparker
your's mentioned code gave me error at this line

For inttables = 1 To crRpt1.Database.Tables.Count

Runtime error '91'
Object variable or with block variable not set

0
 
GJParkerCommented:
I think you need to be using CRAXDRT and not CRAXDDRT

Dim WithEvents CrReport As CRAXDRT.Report
Dim Appl As New CRAXDRT.Application

Public Sub Form_Load()
  Dim intTables As Integer
 
  Set CrReport = "c:\report.rpt"
  For intTables = 1 To CrReport.Database.Tables.Count
       CrReport.Database.Tables(intTables).ConnectionProperties.Item("Password") = "administrator"
  Next intTables

  CrReport.DiscardSavedData
 
  CRViewer91.ReportSource = CrReport 'Sets the Report source of the CrViewer to the Report object we created.

  CRViewer91.ViewReport 'View the Report.
  DoEvents
   
  Exit Sub

Gary
0
 
rehman123Author Commented:
Thanks Parkar ..
0
 
GJParkerCommented:
Glad to help

Gary
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now