I have now found a way round the previous poblem and my code is now:-
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim crConnectionInfo As New ConnectionInfo
Dim crConnServer As String = ConfigurationSettings.AppSettings("CrConnServer")
Dim crConnDbName As String = ConfigurationSettings.AppSettings("CrConnDbName")
Dim crConnUserId As String = ConfigurationSettings.AppSettings("CrConnUserId")
Dim crConnPassword As String = ConfigurationSettings.AppSettings("CrConnPassword")
crConnectionInfo.ServerName = crConnServer
crConnectionInfo.DatabaseName = crConnDbName
crConnectionInfo.UserID = crConnUserId
crConnectionInfo.Password = crConnPassword
crReport.Load("http://localhost/WebServ5/STDPOReportService.asmx")
SetLogOnInfo(crConnServer, crConnDbName, crConnUserId, crConnPassword, "due_in")
SetLogOnInfo(crConnServer, crConnDbName, crConnUserId, crConnPassword, "stores_item")
SetLogOnInfo(crConnServer, crConnDbName, crConnUserId, crConnPassword, "unit_info")
CrystalReportViewer1.ReportSource = crReport
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim MyLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
For Each myTable In crReport.Database.Tables
'[With MyLogonInfo.ConnectionInfo
'End With
MyLogonInfo.ConnectionInfo = crConnectionInfo
myTable.ApplyLogOnInfo(MyLogonInfo)
Next
End Sub
Private Sub SetLogOnInfo(ByVal server As String, ByVal database As String, _
ByVal userID As String, ByVal password As String, ByVal _
table As String)
Dim logOnInfo As New TableLogOnInfo
logOnInfo = crReport.Database.Tables.Item(table).LogOnInfo
' Set the connection information for the table in the report.
logOnInfo.ConnectionInfo.ServerName = server
logOnInfo.ConnectionInfo.DatabaseName = database
logOnInfo.ConnectionInfo.UserID = userID
logOnInfo.ConnectionInfo.Password = Password
logOnInfo.TableName = table
End Sub
End Class
But now I get the message:-
Server Error in '/WebApp5' Application.
Load report failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Load report failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[LoadSaveReportException: Load report failed.]
.I(String , EngineExceptionErrorID )
.E(String , Int32 )
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String reportName)
WebApp5.WebForm1.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
|
Any ideas anyone?