When using Crystal Reports 8.5 with CRViewer in VB6, and it prompts for a password when generating a report, it’s usually due to a missing database login configuration. You need to pass the database credentials programmatically to the report.

SQL Server Login

Solution: Set Database Login Credentials in VB6

Modify your VB6 code to set the database connection properly before displaying the report.

Method 1: Using SetLogOnInfo

If your report connects to an ODBC or direct database, try this:

Dim crApp As New CRAXDRT.Application
Dim crReport As CRAXDRT.Report

Set crReport = crApp.OpenReport("C:\YourReport.rpt")

' Set database login credentials
Dim crTable As CRAXDRT.DatabaseTable
For Each crTable In crReport.Database.Tables
    crTable.SetLogOnInfo "YourServerName", "YourDatabaseName", "YourUsername", "YourPassword"
Next

' Show the report in CRViewer
CRViewer1.ReportSource = crReport
CRViewer1.ViewReport

Replace:

  • “YourServerName” → with your database server name.
  • “YourDatabaseName” → with your database name.
  • “YourUsername” → with the correct database username.
  • “YourPassword” → with the correct password.

Method 2: Using LogOnServer

If you are using ODBC (DSN-based connection):

crReport.Database.LogOnServer "p2sodbc.dll", "YourDSN", "YourDatabase", "YourUsername", "YourPassword"
  • “p2sodbc.dll” → ODBC driver for Crystal Reports.
  • “YourDSN” → Name of the ODBC Data Source Name (DSN).

Method 3: Disable Database Prompt

If you still get a prompt, force the credentials before viewing the report:

crReport.EnableParameterPrompting = False

Let me know if you need further adjustments based on your database type (SQL Server, Oracle, etc.)

SHARE

LEAVE A REPLY

This site uses Akismet to reduce spam. Learn how your comment data is processed.