Click here to Skip to main content
14,733,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a crystal report with sql authentication and by giving username sa and passwd.

and then have created the crystal report.

now in my form at runtime when i am loading the report, it is asking database login details.

and after i enter the password,then data from database is showing in report.

How to disable this?

Because every time i have to do this to see my data in crystal report.

and in my form under button_click, i have just written:- this is the form where crystal report is viewed.

Can anyone help me please how to disable this option.

Thanks in advance
sudeshna from bangkok 25-Aug-13 7:39am
Please can anyone help me.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

put this code into your report button


   Dim Report As New YourReportName' CHANGE YourReportName with your report name
   ' If report name is test.rpt then just use test instead of YourReportName
   Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo

   ConInfo.ConnectionInfo.ServerName = YourServerName ' change with server name
   ConInfo.ConnectionInfo.DatabaseName = YourDatabaseName ' change with database name
   ConInfo.ConnectionInfo.UserID = "sa" 
   ConInfo.ConnectionInfo.Password = YourSaPassword ' change with your password

   For intCounter As Integer = 0 To Report.Database.Tables.Count - 1

   Dim tmpViewer As New YourReportForm ' change with your Crystal Report Viewer control form
   tmpViewer.myCrystalReportViewer.ReportSource = Report

Catch ex As Exception
End Try
try that open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

Data Source: .\Databasename.accdb

and code on viewer form load as

Dim cryRpt As New ReportDocument

Dim Report1 As New rptItemWise

Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)

cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

also change the report connection same as data source i think that code work for you ....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900