TommyGL

Hi, I need help here. Some users unable to view reports with tables connection more than 2 tables. It will prompt a Database Logon screen and everytime users have to enter in the login details to view the reports. Is there anyway to remove the Database Logon screen I have tried to use rptDocument.setDatabaseLogon("username"."password"), but it still prompt me the screen. Please help me out...

Thank you in advance for the help.

coding as follow:

Public ConnString1 As String = "Server=ABC;Database=Setup;User ID=username;Password=password;Trusted_Connection=False"

Public myConnection2 As New SqlConnection(ConnString2)

Dim strsql As String = sqlstr

Dim strrptname As String = rptnamestr

Dim DA As New SqlDataAdapter(strsql, myConnection2)

Dim DS As New DataSet()

DA.Fill(DS)

Dim strReportPath As String = Application.StartupPath & "\" & strrptname & ".rpt"

If Not IO.File.Exists(strReportPath) Then

Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))

End If

'Assign the datasource and set the properties for Report viewer

Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

rptDocument.Load(strReportPath)

rptDocument.SetDataSource(DS.Tables(0))

rptViewer.ShowRefreshButton = False

rptViewer.ShowCloseButton = False

rptViewer.ShowGroupTreeButton = False

rptViewer.ReportSource = rptDocument



Re: Crystal Reports for Visual Studio database login prompt while viewing report

mewdied

If your report is designed off of two tables, you must pass two datatables to it at runtime. In your code you are only passing a single table to the report.



Re: Crystal Reports for Visual Studio database login prompt while viewing report

TommyGL

Sorry but I'm new to VB. Which part of codings above should I change Thank you.



Re: Crystal Reports for Visual Studio database login prompt while viewing report

TommyGL

Found the solution already. Thanks to you all. Below are the codes:

Dim myConnectionInfo As New ConnectionInfo()

myConnectionInfo.DatabaseName = "dbname"

myConnectionInfo.UserID = "username"

myConnectionInfo.Password = "password"

myConnectionInfo.ServerName = "svrname"

SetDBLogonForReport(myConnectionInfo, rptDocument)

plus:

Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)

Dim myTables As Tables = myReportDocument.Database.Tables

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables

Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo

myTableLogonInfo.ConnectionInfo = myConnectionInfo

myTable.ApplyLogOnInfo(myTableLogonInfo)

Next

End Sub