
Crystal Report based on ADO.Net dataset prompts for database login
Hello Mark
You need to do apply the login information for each table
of the report before viewing it. This example assume that
your report name is CrystalReport1 ...
Regards
Jorge Cavalheiro
Dim crReportDocument As New CrystalReport1()
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
'Create an instance of the strongly-typed report
object
crReportDocument = New CrystalReport1()
'Setup the connection information structure to be
used
'to log onto the datasource for the report.
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName= "server"
.DatabaseName = "database"
.UserID = "User name"
.Password = "pass"
End With
'Get the table information from the report
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
'Loop through all tables in the report and apply
the connection
'information for each table.
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo =
crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
'Set the viewer to the report object to be
previewed.
CrystalReportViewer1.ReportSource =
crReportDocument