Unable to connect: incorrect log on parameters.
Hello Experts,
I am having big ptoblems to connect my Crystal Report to MS Access database from inside my ASP.NET application. I did not have any problems to connect to ORACLE, but now I am getting this error:
Error in File c:\inetpub\wwwroot\HABReports\Reports\HABReportWho leTest.rpt: Unable to connect: incorrect log on parameters.
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.LogOnExcept ion: Error in File c:\inetpub\wwwroot\HABReports\Reports\HABReportWho leTest.rpt: Unable to connect: incorrect log on parameters.
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:
[LogOnException: Error in File c:\inetpub\wwwroot\HABReports\Reports\HABReportWho leTest.rpt:
Unable to connect: incorrect log on parameters.]
.L(String , EngineExceptionErrorID )
.G(Int16
, Int32 )
.F(Int16 )
CrystalDecisions.CrystalReports.Engine.FormatEngin e.GetPage(PageRequestContext reqContext)
CrystalDecisions.ReportSource.LocalReportSourceBas e.GetPage(PageRequestContext pageReqContext)
CrystalDecisions.Web.ReportAgent.{(Boolean C)
CrystalDecisions.Web.CrystalReportViewer.OnPreRend er(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Page.ProcessRequestMain()
The code I am using like below, where "MY_DATABASE" is System ODBC DSN name:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim crReportDocument As New ReportDocument
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim sAppPath As String
Dim sFilePath As String
Dim sTmp As String
Dim oEncrDescr As EncrDecr
Try
If Not IsPostBack Then
'Create an instance of the strongly-typed report object
'to make the "Report's Paging" work:
sAppPath = Request.PhysicalApplicationPath.ToString()
sFilePath = sAppPath + "Reports\" + Session("ReportName")
crReportDocument.Load(sFilePath)
'Create the Conection Info object to hold the logon information for the report
crConnectionInfo = New ConnectionInfo
'Populate the ConnectionInfo Objects Properties with the appropriate values for
'the ServerName, User ID, Password and DatabaseName. However, since Oracle
'works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
'Therefore, the DatabaseName property must be set to a BLANK string.
'If the connection is using ODBC, make sure to use the System DSN name as the ServerName
With crConnectionInfo
.ServerName = "MY_DATABASE" 'system ODBC DSN name
.DatabaseName = ""
.UserID = ""
.Password = ""
End With
'Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database
'Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables
'Loop through each Table object in the Tables collection and apply the logon info
'specified ealier. Note this sample only has one table so the loop will only execute once
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
If Session("SelectedRegion") = "SW" Then
crReportDocument.SetParameterValue("[@FromDate]", Session("ReportSAMPLE_DATE_FROM"))
crReportDocument.SetParameterValue("[@ThruDate]", Session("ReportSAMPLE_DATE_TO"))
crReportDocument.SetParameterValue("[@Region]", "SW")
ElseIf Session("SelectedRegion") = "NW" Then
crReportDocument.SetParameterValue("[@FromDate]", Session("ReportSAMPLE_DATE_FROM"))
crReportDocument.SetParameterValue("[@ThruDate]", Session("ReportSAMPLE_DATE_TO"))
crReportDocument.SetParameterValue("[@Region]", "NW")
Else
Session("Message") = "ERROR inside the Page_Load() function. Wrong region has been selected."
Response.Redirect("ErrorForm.aspx", False)
Exit Sub
End If
'Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
CrystalReportViewer1.ReportSource = crReportDocument
End If
Catch ex As Exception 'System.IndexOutOfRangeException
Session("Message") = "ERROR inside the Page_Load() function. " + ex.Message + ". "
Response.Redirect("ErrorForm.aspx", False)
Exit Sub
End Try
End Sub
What am I doing wrong?
Thanks in advance,
Dmitriy
|