Thanks for the reply. But, I can get that part to work when using the crystal reports web viewer and I can login to the database and pass the parameter as expected. The problem is with the next section when I try to create the form with a button that exports the report to Acrobat Reader so it can be printed.
Below is the code I am using that is causing the Login Failed. I have verified the SQL login and it is correct.
Private Sub PDF_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PDF_Button.Click
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String
Dim myReport As New PatDetail
myExportFile = "C:\RPT_TEMP\PDF " & Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With
myReport.Export()
myReport.RecordSelectionFormula = "{Vw_PatLog.PatAccount} = 'XXXXXXXXXXXX'"
myReport.Refresh()
Dim myDBConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
With myDBConnectionInfo
.ServerName = "SERVER"
.DatabaseName = "DATABASE"
.UserID = "USER"
.Password = "PASSWORD"
End With
Dim myTableLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim myDatabase = myReport.Database
Dim myTables = myDatabase.Tables
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
For Each myTable In myTables
myTableLogonInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myDBConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(myExportFile)
Response.Flush()
Response.Close()
System.IO.File.Delete(myExportFile)
End Sub
|